Exemple #1
0
 def login():
     """
     用户登录
     :return: json
     """
     username = request.form.get('username')
     password = request.form.get('password')
     if not username or not password:
         return jsonify(common.resp('', '用户名和密码不能为空', 400))
     else:
         return Auth.authenticate(Auth, username, password)
Exemple #2
0
def token():
    """
    用户登录
    :return: json
    """
    username = request.form.get('username')
    password = request.form.get('password')
    if (not username or not password):
        return jsonify(common.falseReturn('', '用户名和密码不能为空'))
    else:
        return Auth.authenticate(Auth, username, password)
Exemple #3
0
 def login():
     """
     用户登录
     :return: json
     """
     user_name = request.form.get('user_name')
     password = request.form.get('password')
     auth = Auth()
     if (not user_name or not password):
         return jsonify(common.falseReturn('', '用户名和密码不能为空'))
     else:
         return auth.authenticate(user_name, password)
 def login():
     if request.method == 'POST':
         username = request.form.get('username', False)
         password = request.form.get('password', False)
     elif request.method == 'GET':
         username = request.args.get('username', False)
         password = request.args.get('password', False)
     else:
         return jsonify(common.falseReturn('', '请使用POST提交', 103))
     if (not username or not password):
         return jsonify(common.falseReturn('', '用户名和密码不能为空', 102))
     else:
         return Auth.authenticate(Auth, username, password)
Exemple #5
0
def login():
    """
    User Login
    """
    reqParams = request.get_json()
    email = reqParams['email'] if 'email' in reqParams else None
    password = reqParams['password'] if 'password' in reqParams else None

    if (not email or not password):
        return jsonify(
            common.returnFalseMsg('',
                                  'Username and password cannot be empty.'))
    else:
        return Auth.authenticate(Auth, email, password)
Exemple #6
0
 def login():
     username = request.json.get('username')
     password = request.json.get('password')
     if (not username or not password):
         return jsonify(common.falseReturn('', '用户名和密码不能为空'))
     else:
         user_info = Users.find_by_username(username)
         if user_info.count() != 0 and Users.check_password(
                 Users, user_info[0]['password'], password):
             login_tiem = int(time.time())
             token = Auth.authenticate(Auth, username, login_tiem)
             return jsonify(common.trueReturn('成功', token))
         else:
             return jsonify(common.falseReturn('失败', '用户名或密码错误'))