1class User(UserMixin):
2
3 def __init__(self, username, hash):
4 self.name = username
5 self.hash = hash
6
7 @property
8 def id(self):
9 return self.name
10
11
12@self.server.route('/api/login', methods=['GET', 'POST'])
13def login():
14 user = load_user(request.values.get('username'))
15 if user and user.hash == request.values.get('hash'):
16 login_user(user)
17 return jsonify(status='ok', username=user.username)
18 else:
19 return jsonify(status='error', message='wrong username or hash')