Example #1
0
    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
Example #2
0
    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)