Example #1
0
    def post(self):

        data = RegisterUser.get_register_args()

        user = UserModel.find_by_email(data['email'])
        if user:
            return {'msg': 'User with given email already exists!'}, 400

        user = UserModel.find_by_username(data['user_name'])
        if user:
            return {'msg': 'User with given username already exists!'}, 400

        user = UserModel(**data)
        user.save_to_db()

        send_activation_email(user)

        return {'msg': 'Please check mail to activate the account'}, 201
Example #2
0
    def post(self):

        data = User.get_create_args()

        user = UserModel.find_by_email(data['email'])
        if user:
            return {'msg': 'User with given email already exists!'}, 400

        user = UserModel.find_by_username(data['user_name'])
        if user:
            return {'msg': 'User with given username already exists!'}, 400

        user = UserModel(**data)
        user.save_to_db()

        if not current_app.config['TESTING']:
            send_activation_email(user)

        return {'msg': 'Please check mail to activate the account'}, 201