User Login
Adds mutations to handle user login, logout or password reset.
Schema
Base
graphql
"""
The response for the userLogin mutation.
"""
type UserLoginResponse {
"""
Error message.
"""
error: String
"""
Login was successful.
"""
success: Boolean
"""
The user ID if login was successfull.
"""
uid: String
"""
The user name if login was successfull.
"""
name: String
"""
The CSRF token to be used for logging out.
"""
csrfToken: String
"""
The token to use for logging out.
"""
logoutToken: String
}
"""
The response for the userLogout mutation.
"""
type UserLogoutResponse {
"""
Error message if logout was not successfull.
"""
error: String
"""
Logout was successful.
"""
success: Boolean
}
"""
The response for the userPasswordReset mutation.
"""
type UserPasswordResetResponse {
"""
Error message if password reset was not successfull.
"""
error: String
"""
Password reset was successful.
"""
success: Boolean
}
"""
The response for the userPasswordChange mutation.
"""
type UserPasswordChangeResponse {
"""
Error message if password change was not successfull.
"""
error: String
"""
Password change was successful.
"""
success: Boolean
}
"""
The response for the userPasswordResetLogin mutation.
"""
type UserPasswordResetLoginResponse {
"""
Error message if password reset was not successfull.
"""
error: String
"""
Password reset was successful.
"""
success: Boolean
"""
The password reset token for the edit form.
"""
token: String
"""
The logged in user entity.
"""
user: User
}
Extension
graphql
extend type Mutation {
"""
Login with a username or password.
"""
userLogin(username: String!, password: String!): UserLoginResponse
"""
Logout current user.
"""
userLogout(
"""
The logoutToken from the UserLoginResponse.
"""
logoutToken: String!
"""
The csrfToken from the UserLoginResponse.
"""
csrfToken: String!
): UserLogoutResponse
"""
Send a password reset email. Email is used if username is not set.
"""
userPasswordReset(username: String, email: String): UserPasswordResetResponse
"""
Login with a timestamp and hash from the password reset email.
"""
userPasswordResetLogin(id: ID!, timestamp: Int!, hash: String!): UserPasswordResetLoginResponse
"""
Change the password for a given user.
"""
userPasswordChange(id: ID!, newPassword: String!, currentPassword: String, passResetToken: String): UserPasswordChangeResponse
}
Examples
Login
graphql
mutation userLogin($username: String!, $password: String!) {
userLogin(username: $username, password: $password) {
error
success
uid
name
}
}
Request Password Reset
graphql
mutation userPasswordReset($username: String, $email: String) {
userPasswordReset(username: $username, email: $email) {
error
success
}
}
Reset a password
graphql
mutation userPasswordResetLogin($id: ID!, $timestamp: Int!, $hash: String!) {
userPasswordResetLogin(id: $id, timestamp: $timestamp, hash: $hash) {
error
success
token
}
}