Account Registration¶
You can programmatically create a new user account by making a request to the account registration API endpoint, as in the following example:
POST /api/account/register { "nickName": "user1", "email": "user1@example.com", "password": "User123" } Host: https://api.trackmanrange.com
Note that nickName
, email
and password
are all mandatory properties.
If the registration was successful, you'll get back an http 200 response from the server. Otherwise the server is going to return a list of errors in the following form:
{ "errors": [ { "code": "InvalidEmail", "description": "Email 'testmail' is invalid." }, { "code": "PasswordMismatch", "description": "Incorrect password." }, { "code": "PasswordTooShort", "description": "Passwords must be at least 6 characters." } ] }
Check nickName
uniqueness. To check the uniqueness of the nick name use 'check_uniqueness' link returned by the /api
endpoint passing the nick name as a query string parameter.
GET /api/account/uniqueness?nickname=user1 Host: https://api.trackmanrange.com
JSON
response as below. { "isUnique": true }
The account registration and uniqueness endpoint does not require any authentication headers.
Password validation¶
The password policy on server is exposed via an API, same should be used to validate, (if any validation in place), the passwords on client while registering and changing the password.
Use the password_rules
link to get the password validation policy.
POST /api/account/password-rules { "requiredLength": 6, "requireNonAlphanumeric": false, "requireLowercase": false, "requireUppercase": true, "requireDigit": false } Host: https://api.trackmanrange.com
The response fields are self explanatory. Use this link to get get the details. https://docs.microsoft.com/en-us/aspnet/core/api/microsoft.aspnetcore.identity.passwordoptions
The password policy rules endpoint does not require any authentication headers.
Temporary Accounts¶
Players without a TrackMan account, can still create a session and play by acquiring a temporary access token issued by the local Driving Range server. After the session is over, they can decide if they want to create a real account and save their session information. Otherwise the session information is going to be lost.
To create a temporary token, make an http POST request to the create_temp_token
link returned by the /api
endpoint, without passing any data:
POST /api/accounts/token Host: https://localsite.trackmanrange.com
You should get a reponse similar to the following json:
{ "account_id": "a355a98d-f453-4e24-bd68-f16e67533211", "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0NzkyOTk2N", "_links": { "merge_account": { "method": "POST", "href": "https://localsite.trackmanrange.com/api/account/merge" } } }
Merging Accounts¶
If players with a temporary account decide to register or login with their TrackMan account after a play session, they need to merge their TrackMan account with their temporary one. To accomplish that, you need to make an http POST request to the merge_account
link returned when the temporary account was created, using their TrackMan account access token as the Authorization header and passing in their previously acquired temporary token as the body of the request.
This will update their session data so that strokes made with the temporary account, are going to be associated with the TrackMan account instead.
POST /api/account/merge Authorization: Bearer WIiOiJmMzU1YTk4ZC1iNDUz.2OC1mMTZlNjg1MzMyMTMi { "tempAccessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0NzkyOTk2N" } Host: https://localsite.trackmanrange.com
If all goes well, the server is going to respond with a status code of 204 (No Content).