Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download 853 Bytes
Copy Edit Web IDE Raw Blame History
Mendalas authored 2019-06-12 18:07 . new create
from flask_restful import Resource
from auth import auth
from flask import abort, request, jsonify, g, url_for
from user import User
from api import app
class LoginApi(Resource):
def post(self):
if 'username' in request.get_json():
username = request.get_json()['username']
if 'password' in request.get_json():
password = request.get_json()['password']
print "use try login, username:%s, pwd:%s", username, password
user = User.query.filter_by(username='123').first()
if not user:
return jsonify({'status':-1,'errormsg':'用户不存在'})
if not user.verify_password(password):
return jsonify({'status': -2,'errormsg':'密码错误'})
token = user.generate_auth_token(600)
return jsonify({'status':0,'token': token.decode('ascii'), 'duration': 600})

Comment ( 0 )

Sign in for post a comment