def on_post(self, req, res): session = req.context['session'] user_req = self.load_request(req, res) if user_req is not None: auth_id = AUTH_ID_EMAIL % user_req['email'] user = User() user.username = user_req['username'] user.email = user_req['email'] user.password = hash_password(user_req['password']).decode('utf-8') user.lat = user_req['lat'] user.lng = user_req['lng'] user.phone = user_req['phone'] user.auth_id = auth_id user.token = encrypt_token(auth_id + ':' + uuid()).decode('utf-8') user.attr = user_req['attr'] session.add(user) res.status = falcon.HTTP_201 res.body = self.to_json({ 'meta': { 'code': 201 } }) else: self.abort(falcon.HTTP_400, "Invalid Parameter")
def on_post(self, req, res): session = req.context["session"] user_req = req.context["data"] if user_req: user = User() user.username = user_req["username"] user.email = user_req["email"] user.password = hash_password(user_req["password"]).decode("utf-8") user.info = user_req["info"] if "info" in user_req else None sid = uuid() user.sid = sid user.token = encrypt_token(sid).decode("utf-8") session.add(user) userData = { "username": user.username, "email": user.email, "info": user.info, "_id": sid, "user_id": user.sid, "token": user.token } self.on_success(res, userData) else: raise InvalidParameterError(req.context["data"])
def on_post(self, req, res): session = req.context["session"] user_req = req.context["data"] if user_req: user = User() user.email = user_req["email"] user.password = hash_password(user_req["password"]).decode("utf-8") sid = uuid() user.sid = sid user.token = encrypt_token(sid).decode("utf-8") session.add(user) self.on_post_success(res, None) else: raise InvalidParameterError(req.context["data"])
def on_post(self, req, res): session = req.context['session'] user_req = req.context['data'] if user_req: user = User() user.username = user_req['username'] user.email = user_req['email'] user.password = hash_password(user_req['password']).decode('utf-8') user.info = user_req['info'] if 'info' in user_req else None sid = uuid() user.sid = sid user.token = encrypt_token(sid).decode('utf-8') session.add(user) self.on_success(res, None) else: raise InvalidParameterError(req.context['data'])