Ejemplo n.º 1
0
 def session_check(package):
     params = package['params']
     ip_address = package['ip']
     session = SessionHelper.get_session_id(params[ParamType.Token], ip_address)
     error = None
     if session is None:
         error = Response.error_response('No Session')
     else:
         package['session'] = session
         package['user'] = UserHelper.get_user_by_session(session)
     return package, error
Ejemplo n.º 2
0
def change_password(package):
    """process the request of changing password
    """
    session = package.get('session')
    params = package.get('params')
    oldpassword = params.get(ParamType.OldPassword)
    newpassword = params.get(ParamType.NewPassword)

    user = UserHelper.get_user_by_session(session)
    if user is None:
        return Response.error_response('No User')

    if not UserHelper.signin_check_password(user, oldpassword):
        return Response.error_response('Old Password Error')

    info = {'password': newpassword}
    user_id = user.get('id')
    UserHelper.modify_user(user_id, info)

    return Response.success_response(None)