sCAuth

sCAuth

The sCAuth instance communicates with the authentication service of the schmuckliCloud API.

Constructor

new sCAuth(app_id, app_secret, service_urlopt)

Opens a new schmuckliCloud authentication instance. It can be used to manage then all the data in a defined project.

Parameters:
Name Type Attributes Description
app_id String

The APP ID, which was created for a client app in the schmuckliCloud console.

app_secret String

The APP Secret, which was created for a client app in the schmuckliCloud console.

service_url String <optional>

If you want to replace the backend url instead of https://api.schmuckli.cloud/client_api/v1/auth/, provide here the new path.

Source:

Methods

(async) registerEmailPassword(email, password, language) → {Promise.<sCResult>}

Adds a new user to the authentication system.

Parameters:
Name Type Description
email string

The new email

password string

The new password

language string

A two letter language code (ex. de, en)

Source:

(async) authorizeEmailPassword(email, password, otp_codeopt) → {Promise.<sCResult>}

Authorizes the user with email and password. In the body you will find the session token.

Parameters:
Name Type Attributes Description
email string

The email of the user

password string

The password of the user

otp_code int <optional>

The six digit one time password. Only needed when backend responds the first time with status code 300.

Source:

(async) updatePassword(email, old_password, new_password) → {Promise.<sCResult>}

Updates the password of the given email for the user in the project.

Parameters:
Name Type Description
email string

The email of the user, where the password should be changed.

old_password string

The current password of the user.

new_password string

The new password of the user.

Source:

(async) requestResetPassword(email) → {Promise.<sCResult>}

If the user has forgottten his password, just provide the email and it will send an email with a password change link.

Parameters:
Name Type Description
email string

The email from the account (ex. EmailPassword or any other provider)

Source:

(async) updateResetPassword(reset_token, password) → {Promise.<sCResult>}

Updates the password for the user, after he has clicked the link in the received mail.

Parameters:
Name Type Description
reset_token string

The reset token, provided from the sent email to the user.

password string

The new password for the user.

Source:

(async) activateUser(token) → {Promise.<sCResult>}

Call this function, if the user has clicked on the activation link in the welcome email.

Parameters:
Name Type Description
token string

The token, which was given through the parameter in the email link.

Source:

(async) checkSession(token) → {Promise.<sCResult>}

Checks if the token provided is still valid and matches with the server.

Parameters:
Name Type Description
token string

The session token, which you got, when the user has been authorized.

Source:

(async) getUserDetails(token) → {Promise.<sCResult>}

Gets more detailed information about the signed in user.

Parameters:
Name Type Description
token string

The token of the current session.

Source:

(async) getActiveSessions(token) → {Promise.<sCResult>}

Get all active session for the user.

Parameters:
Name Type Description
token string

The token of the current session.

Source:

(async) logout(token) → {Promise.<(sCResult|Error)>}

Removes the current active session, which was given.

Parameters:
Name Type Description
token string

The session token of the current logged in session.

Source:

(async) removeSession(current_token, id) → {Promise.<sCResult>}

Removes a session by the session id.

Parameters:
Name Type Description
current_token string

The token, where the user is currently signed in.

id int

The session id, which should be removed.

Source:

generateSetupTOTP(token) → {Promise.<sCResult>}

Call this function when the user wants to setup the two factor authentication for his account.

Parameters:
Name Type Description
token string

The session token of the currently signed in user.

Source:

verifySetupTOTP(token, code) → {Promise.<sCResult>}

Call this function when the user wants to verify the code to finish the setup of the two factor authentication.

Parameters:
Name Type Description
token string

The session token of the currently signed in user.

code string

The six digit code, generated from the secret.

Source:

disableOTP(token) → {Promise.<sCResult>}

Disables the OTP option from the account.

Parameters:
Name Type Description
token string

The session token from the signed in user.

Source:

requestExport(token) → {Promise.<sCResult>}

Creates an export of a user and sends it via mail.

Parameters:
Name Type Description
token String

The token of the user, from where the export should be made.

Source:

deleteAccount(token, password) → {Promise.<sCResult>}

Deletes an account completly from the system. This step cannot be undone.

Parameters:
Name Type Description
token String

The token of the user, from where the export should be made.

password String

The unhashed password to verify, if the user really wants to delete the account.

Source: