push access token if registered
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
308184f4cf
commit
2a1be04fb3
@ -55,8 +55,10 @@ class SignupApi(Resource):
|
||||
current_app.logger.warning(e)
|
||||
abort(503, "user already exists")
|
||||
|
||||
expires = datetime.timedelta(days=7)
|
||||
access_token = create_access_token(identity=str(user.name), expires_delta=expires)
|
||||
db.session.commit()
|
||||
return self.usermetadataschema.dump(user), 200
|
||||
return {'token': access_token}, 200
|
||||
|
||||
|
||||
class LoginApi(Resource):
|
||||
@ -75,11 +77,14 @@ class LoginApi(Resource):
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(417, INVALID_JSON_SCHEMA_MSG)
|
||||
|
||||
user = VideonUser.query.filter_by(name=userobj['name']).first_or_404()
|
||||
authorized = user.check_password(userobj['password'])
|
||||
if not authorized:
|
||||
abort(401, "username or password incorrect")
|
||||
try:
|
||||
user = VideonUser.query.filter_by(name=userobj['name']).first()
|
||||
authorized = user.check_password(userobj['password'])
|
||||
if not authorized:
|
||||
abort(401, "username or password incorrect")
|
||||
except Exception as e:
|
||||
current_app.logger.info(e)
|
||||
abort(401, "unauthorized")
|
||||
|
||||
try:
|
||||
user.last_logon = datetime.datetime.now()
|
||||
|
Loading…
Reference in New Issue
Block a user