In the previous post, we have seen implementing User defined functions using createAccount API.
Let’s check how to use the login
or loginByEmail
APIs to login a student account using the User Defined Function.
Example
You can login with loginStudentAccount
function using username
and password
. emailLoginStudentAccount
function accepts email
and password
as inputs to login a student account. It uses the login
API to login a student Account.
type Query {
loginStudentAccount(email: String! password: String! ): AccessToken
@tan(type:Groovy, inline: """return loginByEmail(email, password)""")
emailLoginStudentAccount(username: String! password: String! ): AccessToken
@tan(type:Groovy, inline: """return login(username, password)""")
}
Let’s execute the functions!
{
loginStudentAccount(username:"hypi-user1",password:"hypi-user1@hypi.io"){
sessionToken
sessionExpires
errorCode
errorMsg
}
}
OR
{
emailLoginStudentAccount(email:"hypi-user2@hypi.io",password:"hypi-user2@hypi.io"){
sessionToken
sessionExpires
errorCode
errorMsg
}
}
#result
{
"data": {
"loginStudentAccount": {
"sessionToken": "Auth-Token",
"sessionExpires": 1628078182,
"errorCode": null,
"errorMsg": null
}
}
}