def post(self): args = request.data marshalled = utils.marshal_request(args, arguments['POST']) marshal_error = utils.make_marshal_error(marshalled) if marshal_error: return marshal_error args = marshalled[0] args['active'] = True if args.get('password') != args.get('confirmedPassword'): message = "Confirmed password did not match password" source = "confirmedPassword" return utils.make_error(errors.InvalidParameterError(message, [source])) existing_user = user_service.find_by_email(args.get('email')) if existing_user: message = "The user " + args.get('email') + " already exists" source = "email" return utils.make_error(errors.InvalidParameterError(message, [source])) user = None try: user = user_service.create(args) except exceptions.ValidationException, e: return utils.make_validation_error(e)
def post(self): args = request.data marshalled = utils.marshal_request(args, arguments['POST']) marshal_error = utils.make_marshal_error(marshalled) if marshal_error: return marshal_error args = marshalled[0] args['active'] = True if args.get('password') != args.get('confirmedPassword'): message = "Confirmed password did not match password" source = "confirmedPassword" return utils.make_error( errors.InvalidParameterError(message, [source])) existing_user = user_service.find_by_email(args.get('email')) if existing_user: message = "The user " + args.get('email') + " already exists" source = "email" return utils.make_error( errors.InvalidParameterError(message, [source])) user = None try: user = user_service.create(args) except exceptions.ValidationException, e: return utils.make_validation_error(e)
def post(self): args = request.data marshalled = utils.marshal_request(args, arguments['POST']) marshal_error = utils.make_marshal_error(marshalled) if marshal_error: return marshal_error args = marshalled[0] user = user_service.find_by_email(args['email']) if not user: message = 'User %s not found' % args['email'] source = 'email' return utils.make_error(errors.InvalidParameterError(message, source)) if not user_service.password_matches(user, args['password']): message = 'Password is incorrect' source = 'password' return utils.make_error(errors.InvalidParameterError(message, source)) token = auth_service.make_token(user) return utils.make_response(data = { 'token': token })