Authentication views¶
- sol.views.auth.auth_user(request)¶
Verify the credentials of an user.
URL
/auth/loginMethod
POSTResponse
JSONParameters
username
the name of the user
password
its password
Upon successful authentication, the client receives back a
JSONstructure containing information about the user and his preferences, and asessioncookie.Invalid credentials
curl --silent \\ --data "username=foo" \\ --data "password="bar" \\ http://server.sol/auth/login
$params = @{ Uri = 'http://server.sol/auth/login' Method = 'POST' Body = @{ username = "foo" password = "bar" } } (Invoke-WebRequest @params).Content
This emits a
JSONresponse similar to the following:{ "success": false, "message": "The inserted user and password, or one of the two, are wrong!", "errors": { "username": "Invalid credentials", "password": "Invalid credentials" } }
Successful call
curl --silent \\ --data "username=lele" \\ --data "password=therightpassword" \\ --cookie-jar cookies.txt \\ http://server.sol/auth/login
$params = @{ Uri = 'http://server.sol/auth/login' Method = 'POST' Body = @{ username = "lele" password = "therightpassword" } } $res = Invoke-WebRequest @params $ses.Cookies | Export-Clixml -Path "cookies.txt"
This time the
JSONresponse contains something like:{ "success": true, "fullname": "Lele Gaifax", "is_admin": false, "is_nationalliable": null, "is_ownersadmin": true, "is_playersmanager": true, "user_id": 1, "maxratinglevel": "2", "reload_l10n": false, "ui_language": null, "modules": [ "…" ], "shortcuts": [ "…" ], "quickstart": [ "…" ] }
- sol.views.auth.logout(request)¶
Conclude the session of the user, logging him out.
URL
/auth/logoutMethod
GETResponse
JSONThis can be called only by an
authenticated user.Unauthorized call
curl --silent --out-null \\ --write-out '%{http_code}\n' \\ http://server.sol/auth/logout
401$params = @{ Uri = 'http://server.sol/auth/login' } $res = Invoke-WebRequest @params $res.StatusCode
401Successful call
curl --silent \\ --cookie cookies.txt \\ http://server.sol/auth/logout
$ses = Import-Clixml -Path "cookies.txt" $params = @{ Uri = 'http://server.sol/auth/logout' Method = 'POST' SessionVariable = 'ses' } (Invoke-WebRequest @params).Content
The
JSONresponse contains something like:{ "success": true, "message": "Goodbye" }
- sol.views.auth.create_new_user(request)¶
First step of the sign-in workflow.
URL
/auth/signinMethod
POSTResponse
JSONParameters
email
the email address of the new account
password
the password of the new account
firstname
the first name of the user
lastname
the family name of the user
language
the preferred language
Once an anonymous visitor fills the self registration form and confirms the data this method validates it and if everything is good a new
useris created and an email is sent to the new potential user, with anURLshe must visit tocompletethe procedure.
- sol.views.auth.confirm_new_user(request)¶
Second step of the sign-in workflow.
URL
/auth/signinMethod
GETResponse
HTMLParameters
confirm
the signed id of the new user
This concludes the self registration procedure: if confirm is valid the new account is activated and the visitor is redirected to the login page.
- sol.views.auth.lost_password(request)¶
First step of the reset password workflow.
URL
/auth/lost_passwordMethod
POSTResponse
JSONParameters
email
the user's email address
This sends an email to the specified address, with an
URLthat the user must visit to reset her own password.
- sol.views.auth.reset_password(request)¶
Second step of the reset password workflow.
URL
/auth/reset_passwordMethod
POSTResponse
JSONParameters
token
a signed token
password
the new password
This changes the user's password to a new one.
- sol.views.auth.change_password(request)¶
Change the user's password
URL
/auth/change_passwordMethod
POSTResponse
JSONParameters
oldpassword
the old password
newpassword
the new password
This replaces oldpassword with newpassword for the authenticated user.
Unauthorized call
curl --silent --out-null \\
--write-out '%{http_code}\n' \\
http://server.sol/auth/change_password
401
$params = @{ Uri = 'http://server.sol/auth/change_password' }
$res = Invoke-WebRequest @params
$res.StatusCode
401
Successful call
curl --silent \\
--cookie cookies.txt \\
--data "oldpassword=foo" \\
--data "newpassword=bar" \\
http://server.sol/auth/change_password
$ses = Import-Clixml -Path "cookies.txt"
$params = @{
Uri = 'http://server.sol/auth/change_password'
Method = 'POST'
SessionVariable = 'ses'
Body = @{
oldpassword = 'foo'
oldpassword = 'bar'
}
}
(Invoke-WebRequest @params).Content
The JSON response contains something like:
{
"success": true
}
- sol.views.auth.change_language(request)¶
Change the user's preferred language.
URL
/auth/change_languageMethod
POSTResponse
JSONParameters
language
the ISO code of the language
This sets the language used by the
UIfor the authenticated user.
Unauthorized call
curl --silent --out-null \\
--write-out '%{http_code}\n' \\
http://server.sol/auth/change_language
401
$params = @{ Uri = 'http://server.sol/auth/change_language' }
$res = Invoke-WebRequest @params
$res.StatusCode
401
Successful call
curl --silent \\
--cookie cookies.txt \\
--data "language=xy" \\
http://server.sol/auth/change_language
$ses = Import-Clixml -Path "cookies.txt"
$params = @{
Uri = 'http://server.sol/auth/change_language'
Method = 'POST'
SessionVariable = 'ses'
Body = @{
language = 'xy'
}
}
(Invoke-WebRequest @params).Content
The JSON response contains something like:
{
"success": true
}