Commit dba3393541152b943c2b50373ccff262049bfcc2

Authored by Яна Степаненко
1 parent e3b1c2ee47

fix register

Showing 10 changed files with 4 additions and 3 deletions Side-by-side Diff

__pycache__/main.cpython-310.pyc
No preview for this file type
__pycache__/routes.cpython-310.pyc
No preview for this file type
components/adm/__pycache__/__init__.cpython-310.pyc
No preview for this file type
components/adm/adm/__pycache__/views.cpython-310.pyc
No preview for this file type
components/adm/adm/views.py
... ... @@ -17,14 +17,15 @@
17 17 def register():
18 18 params = request.json
19 19 session = k2.extensions['sqlalchemy'].db.session
20   - try:
  20 + exist = session.query(k2users).filter_by(login=request.json['login']).first()
  21 + if not exist:
21 22 user = k2users(**params)
22 23 session.add(user)
23 24 session.commit()
24 25 token = user.get_token()
25 26 return {'access_token': token}
26   - except:
27   - return jsonify({'error': 'Unauthorized'}), 401
  27 + else:
  28 + return jsonify({'error': 'User exist'}), 401
28 29  
29 30  
30 31 @adm.route('/login', methods=["POST"])
components/k2test/k2test/__pycache__/views.cpython-310.pyc
No preview for this file type
k2/__pycache__/__init__.cpython-310.pyc
No preview for this file type
k2/__pycache__/k2cfg.cpython-310.pyc
No preview for this file type
k2/__pycache__/k2inst.cpython-310.pyc
No preview for this file type
k2/__pycache__/k2obj.cpython-310.pyc
No preview for this file type