Skip to content

Instantly share code, notes, and snippets.

@aSemy
Last active June 1, 2018 08:56
Show Gist options
  • Save aSemy/bac34069ba5a9bfe7d8e98917a939f19 to your computer and use it in GitHub Desktop.
Save aSemy/bac34069ba5a9bfe7d8e98917a939f19 to your computer and use it in GitHub Desktop.
@Component
public class UserRegisterMutator {
public static final String REGISTER_ARGUMENT_NAME = "userRegisterRequest";
/**
* @param userRegisterRequest Contains info about the user's registration, e.g. their name
*
* @return Always returns true, so potential attackers get no info. Valid attempts will get an email.
*/
@GraphQLMutation(name = "userRegister")
@PreAuthorize("permitAll()")
public boolean userRegister(@GraphQLArgument(
name = REGISTER_ARGUMENT_NAME) @GraphQLNonNull final UserRegisterRequest userRegisterRequest) {
// user registration stuff
// ...
// always return true, otherwise attacks can work out the emails of users who have already registered
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment