def post(cls): value = parser.parse_args() user = UserModel.findByEmail(value.email) if user and safe_str_cmp(user.password, value.password): return cls.newToken(user) return gettex('NOT_FOUND'), 400
def post(self): value = request.get_json() values = userschema.load(value,partial = ('registerDate','name',)) user = UserModel.findByEmail(values.email) if user and safe_str_cmp(user.password,values.password): confirmation = user.recentConfirmation if confirmation and confirmation.confirmed: # if activated return self.generateToken(user.userId) # do an activate user return gettext('emailNotConfirm').format(user.email) return log.ISNOTEXIST(),404
def post(self): value = request.get_json() value.update({'registerDate': int(time())}) user = userschema.load(value) isName = UserModel.findByName(user.name) isEmail = UserModel.findByEmail(user.email) if isName is None and isEmail is None: user.insert() # savetodatabase confirm = ConfirmationModel(user.userId) confirm.insert() user.sendMsg() return userschema.dump(user) return log.ISEXIST(), 400
def post(self): value = req.get_json() value.update({'userId': uuid4().hex}) user = UserSchema().load(value, session=db.session) isEmail = bool(UserModel.findByEmail(user.email)) isName = bool(UserModel.findByName(user.name)) if isEmail or isName: return gettex('EXIST'), 422 try: user.insert() except: return gettex('SOMETHING_WRONG'), 500 return UserSchema().dump(user)
def get(cls): params = request.args res = github.authorized_response() if res is None or res.get('access_token') is None: return { "error": params['error'], } g.access_token = res['access_token'] github_user = github.get('user') value = { "email": github_user.data['email'], "name": github_user.data['login'], "registerDate": int(time()) } user = UserModel.findByEmail(value['email']) if user is not None: return Authenticate.generateToken(user.userId) newuser = userschema.load(value, partial=('password', )) newuser.insert() return Authenticate.generateToken(newuser.userId)