Пример #1
0
def editPerson():
    surname = request.form.get('surname')
    forename = request.form.get('forename')
    location = request.form.get('location')
    email = request.form.get('email')
    url = request.form.get('url')
    tagline = request.form.get('tagline')
    is_disabled = request.form.get('is_disabled')
    nyunetid = request.form.get('nyunetid')


    # Get person by auth token 
    current_token = get_raw_jwt()
    jti = current_token['jti']

    # email address
    if request.form.get('person_id') is None:
        identity = current_token['identity']
    else:
        identity = request.form.get('person_id')

    try:
        return makeResponse(payload=PeopleManager.editPerson(identity, forename, surname, location, email, url, tagline, is_disabled, nyunetid), message="")
    except FindError as e:
        return makeResponse(error=e)
    except ValidationError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
    except SaveError as e:
        return makeResponse(error=e)
    except Exception as e:
        return makeResponse(error=e)
Пример #2
0
def getPersonRepos():
    identity = request.form.get('person_id')
    if identity is None:
        current_token = get_raw_jwt()
        identity = current_token['identity']

    try:
        return makeResponse(payload=PeopleManager.getReposForPerson(identity))
    except FindError as e:
        return makeResponse(error=e)
Пример #3
0
def logout():
    try:
        current_token = get_raw_jwt()
        jti = current_token['jti']
        revoke_token(jti)
        return makeResponse(payload={}, message="Logged out")
    except KeyError as e:
        return makeResponse(error=e)
    except Exception as e:
        return makeResponse(error=e)
Пример #4
0
def logout():
    """
    Logout the user by revoking their token.

    :rtype: flask.Response
    """
    jwt = get_raw_jwt()
    # Store the token in the database status of not currently revoked
    BlacklistedToken.add_token(jwt)
    return jsonify({'message': 'You were logged out successfully'})
Пример #5
0
def refresh(body=None, token_info=None, user=None):
    current_user_id = get_jwt_identity()
    user = User.query.filter(User.id == current_user_id).first()
    if user is None:
        revoke_token(get_raw_jwt())
        return Problem(
            UNAUTHORIZED_ERROR,
            'Could not grant access token.',
            'User {} from refresh JWT identity could not be found.'.format(current_user_id))
    if user.active:
        return {'access_token': create_access_token(identity=current_user_id, fresh=False)}, OBJECT_CREATED
    else:
        return user_deactivated_problem
Пример #6
0
def setRepoOwner(repo_id):
    # Get person by auth token
    current_token = get_raw_jwt()
    jti = current_token['jti']

    # email address
    identity = current_token['identity']
    ident_str = "p.email = {identity}"

    try:
        RepoManager.setOwner(int(repo_id), identity, ident_str)
        return makeResponse(payload={}, message="Set repository owner")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Пример #7
0
def addRepo():
    url = request.form.get('url')
    name = request.form.get('name')
    readme = request.form.get('readme')
    license = request.form.get('license')
    published = request.form.get('published')

    # Get person by auth token
    current_token = get_raw_jwt()
    jti = current_token['jti']

    # email address
    identity = current_token['identity']
    ident_str = "p.email = {identity}"

    try:
        return makeResponse(payload=RepoManager.create(url, name, readme, license, published, identity, ident_str), message="Created repository")
    except ValidationError as e:
        return makeResponse(error=e)
Пример #8
0
def getPerson():
    if request.method == 'GET':
      # Get person by auth token 
      current_token = get_raw_jwt()
      jti = current_token['jti']

      # email address
      identity = current_token['identity']

    if request.method == 'POST':
      identity = int(request.form.get('person_id'))

    person = PeopleManager.getInfo(identity)

    ret = {}
    if person is not None:
      ret['person'] = person

    # If request method is GET, then it's our logged in user, get Repos and repo data too!
    if request.method == 'GET':
      ret['repos'] = PeopleManager.getRepos(identity)

    return makeResponse(payload=ret)
Пример #9
0
 def post(self):
     jti = get_raw_jwt()['jti']  # jti is "JWT ID", a unique identifier for a JWT.
     BLACKLIST.add(jti)
     return {"message": "Successfully logged out"}, 200
Пример #10
0
 def delete(self):
     jti = get_raw_jwt()['jti']
     blacklist.add(jti)
     return response("OK", msg="Successfully logged out")
Пример #11
0
 def post(self):
     jti = get_raw_jwt()['jti']
     BLACKLIST.append(jti)
     return {"message": "Successfully logged out"}, 200
Пример #12
0
def dashboard():
    user = get_raw_jwt()['identity']
    return render_template('dashboard.html', user=user)
Пример #13
0
def protected():
    app.logger.info('Processing default request')
    username = get_jwt_identity()
    tt = get_raw_jwt()
    return jsonify(logged_in_as=tt), 200
Пример #14
0
 def post(cls):
     # jti is "JWT ID" unique identifier for a JWT
     jti = get_raw_jwt()["jti"]
     BLACKLIST.add(jti)
     return {"message": USER_LOGGED_OUT}, 200
Пример #15
0
 def post(self):
     access_id = get_raw_jwt()['jti']
     BLACKLIST.add(access_id)
     return {"message": "Logout successful"}
Пример #16
0
 def post(self):
     jti = get_raw_jwt()['jti']
     BLACKLIST.append(jti)
     return send_success('Success', {'message': 'successfully logged out.'},
                         status.HTTP_200_OK)
Пример #17
0
 def post(self):
     jti = get_raw_jwt()[
         'jti']  #jti is jwt id , a unique identifier for a JWT
     BLACKLIST.add(jti)
     return {'message': 'Successfully logged out'}, 200
Пример #18
0
def revoke_access_token():
    jti = get_raw_jwt()['jti']
    user_identity = get_jwt_identity()
    revoke_token(jti, user_identity)
    return jsonify({'message': 'token revoked'}), 200
Пример #19
0
 def post(self):
     # use balaclist current token instead of user id
     jti = get_raw_jwt()[
         'jti']  # jti is "JWT ID", an unique identifier for JWT
     BLACKLIST.add(jti)
     return {'message': 'Sucessfully logged out.'}, 200
Пример #20
0
 def post(self):
     jti = get_raw_jwt()['jti']  #jti == JWT ID
     print(jti)
     BLACKLIST.add(jti)
     print(len(BLACKLIST))
     return {'message': 'Successfully logged out ✌🏿'}, 200
 def claims():
     jwt = get_raw_jwt()
     claims_keys = [claim for claim in jwt]
     return jsonify(claims_keys), 200
Пример #22
0
 def post(cls):
     jti = get_raw_jwt()["jti"]  # jti is "JWT ID", a unique identifier for a JWT.
     user_id = get_jwt_identity()
     BLACKLIST.add(jti)
     return {"message": USER_LOGGED_OUT.format(user_id)}, 200
Пример #23
0
 def post(self):
     jwt_id = get_raw_jwt()['jti']  # JWT Token Identifier
     BLACKLIST.add(jwt_id)
     return {"message": "Logged out successfully!"}, 200
Пример #24
0
 def post(cls):
     jti = get_raw_jwt().get('jti')  # jti is "JWT ID", a unique identifier for a JWT
     user_id = get_jwt_identity()
     BLACKLIST.add(jti)
     return {'message': gettext('user_logged_out').format(user_id)}, 200
Пример #25
0
 def post(self):
     jwt_id = get_raw_jwt()['jti']  #JWT Token Identifier
     BLACKLIST.add(jwt_id)
     return {'message': 'Até breve'}
Пример #26
0
def logout():
    jti = get_raw_jwt()['jti']
    blacklist.add(jti)
    return 'berhasil logout'
Пример #27
0
def revoke_refresh_token():
    jti = get_raw_jwt()['jti']
    user_identity = get_jwt_identity()
    revoke_token(jti, user_identity)
    return jsonify({"message": "token revoked"}), 200
Пример #28
0
def logout():
    jti = get_raw_jwt()['jti']
    blacklist.add(jti)
    return jsonify({"msg": "Successfully logged out"}), 200
Пример #29
0
 def post(self):
     jwt_id = get_raw_jwt()['jti']
     BLACKLIST.add(jwt_id)
     return {'message': 'Logged out successfully!'}, 200
Пример #30
0
 def post(self):
     jti = get_raw_jwt()["jti"]  # jti is "JWT ID", a unique identifier for a JWT.
     user_id = get_jwt_identity()
     BLACKLIST.add(jti)
     return {"message": "User <id={}> successfully logged out.".format(user_id)}, 200
Пример #31
0
 def post(self):
     jti = get_raw_jwt()['jti']
     BLACKLIST.add(jti)
     return {"message": "Successfully logged out"}, 200
Пример #32
0
 def post(cls):
     """Blacklist used token"""
     jti = get_raw_jwt()['jti']  # jti is JWT ID
     BLACKLIST.add(jti)
     return {'message': gettext("user_logged_out")}, 200
Пример #33
0
 def post(cls):
     jti = get_raw_jwt()["jti"]  # jti is "JWT ID", a unique identifier for a JWT.
     user_id = get_jwt_identity()
     BLACKLIST.add(jti)
     return {"message": gettext("user_logged_out").format(user_id=user_id)}, 200
Пример #34
0
 def post(self):
     jti = get_raw_jwt()["jti"]  # jti is "JWT ID", a unique identifier for a JWT.
     blacklist.add_to_blacklist(jti)
     return {MESSAGE: "Successfully logged out"}, 200
 def post(self):
     revoked_tokens.append(get_raw_jwt()["jti"])
     return make_response(jsonify({'message': 'Successfully logged out'}),
                          200)
Пример #36
0
 def post(self):
     jti = get_raw_jwt()[
         'jti']  # jit is "JWT ID", a unique identifier for that JWT
     user = UserModel.find_by_id(get_jwt_identity()).json()['username']
     BLACKLIST.add(jti)
     return {'message': '{} has successfully logged out.'.format(user)}
Пример #37
0
 def post(self):
     jti = get_raw_jwt()['jti']
     revoked_token = RevokedToken(jti=jti)
     revoked_token.add()
     return {"success": True}, 200
Пример #38
0
def logout():
    '''Route to logut'''
    dump = get_raw_jwt()['jti']
    blacklist.add(dump)
    return jsonify({'message': 'Logout successful'}), 200
Пример #39
0
def _revoke_current_token():
    current_token = get_raw_jwt()
    jti = current_token['jti']
    revoke_token(jti)
Пример #40
0
 def get(cls):
     resp = make_response(
         render_template("/create_item.html",
                         csrf_token=(get_raw_jwt() or {}).get("csrf")))
     return resp
Пример #41
0
def revoke_refresh_token():
    jti = get_raw_jwt()['jti']
    user_identity = get_jwt_identity()
    revoke_token(jti, user_identity)
    return jsonify({"message": "token revoked"}), 200
Пример #42
0
def logout_refresh_token():
    blacklist.add(get_raw_jwt()["jti"])
    return jsonify(message="Successfully logged out.")
 def post(self):
     jti = get_raw_jwt()['jti']  # jti is "JWT ID", a unique identifier for a JWT.
     BLACKLIST.add(jti)
     return {"message": "Successfully logged out"}, 200