def post(self): try: args = self.parser.parse_args() email = args['email'] password = args['password'] user = User.query.filter_by(email=email).first() if user: if sha256_crypt.verify(password, user.password): access_token = create_access_token(identity=to_dict(user), expires_delta=False) refresh_token = create_refresh_token( identity=to_dict(user)) return jsonify(status="success", access_token=access_token, refresh_token=refresh_token, user=to_dict(user)) else: return jsonify(status="error", message="app.auth.login_error") else: return jsonify(status="error", message="app.auth.login_error") except Exception as e: print(e) return jsonify(status="error", message="app.global.error"), 500
def post(self): try: args = self.parser.parse_args() password = args['password'] verifPassword = args['verifPassword'] last_user = get_jwt_identity() if sha256_crypt.verify(verifPassword, last_user['password']): user = User.query.filter_by(id=last_user['id']).first() user.email = args['email'] user.username = args['username'] user.firstname = args['firstname'] user.lastname = args['lastname'] user.language = args['language'] if password != '': user.password = sha256_crypt.hash(args['password']) db.session.add(user) db.session.commit() access_token = create_access_token(identity=to_dict(user)) refresh_token = create_refresh_token(identity=to_dict(user)) return jsonify(status="success", access_token=access_token, refresh_token=refresh_token) else: return jsonify(status="error", message="app.auth.password_mismatch") except Exception as e: return jsonify(status="error", message="app.global.error")
def post(self): try: args = self.parser.parse_args() _id = args['id'] return jsonify(to_dict(User.query.filter_by(id=_id).first())) except Exception as e: return jsonify(status="error", message="{}".format(e)), 500
def get(self): try: user = get_jwt_identity() id = user['id'] new_user = User.query.filter_by(id=id).first() return jsonify( status="success", access_token=create_access_token(identity=to_dict(new_user))) except Exception as e: return jsonify(status="error", message="{}".format(e)), 500
def get(self): try: return jsonify([to_dict(user) for user in User.query.all()]) except Exception as e: return jsonify(status="error", message="{}".format(e)), 500