File

src/app/auth/auth.service.ts

Description

Service for user authentication on the SWIM platform

Index

Properties
Methods

Constructor

constructor(http: HttpClient, http2: HttpClient, router: Router, handler: HttpBackend)

Class contructor

Parameters :
Name Type Optional Description
http HttpClient No

http service

http2 HttpClient No

http service 2

router Router No
handler HttpBackend No

Methods

autoLogin
autoLogin()

renew login

Returns : void
autoLogout
autoLogout(expirationDuration: number)

Logout when token expires

Parameters :
Name Type Optional Description
expirationDuration number No

time to expire

Returns : void
changePassword
changePassword(oldP: string, newP: string)

Change password of conected user

Parameters :
Name Type Optional Description
oldP string No

old password

newP string No

new password

Returns : any
guest
guest()

Auto login guest user

Returns : void
guestLogin
guestLogin(isGuest: boolean)

On submit login Dev endpoint: http://localhost:3000/api/authenticate

Parameters :
Name Type Optional
isGuest boolean No
Returns : any
Private handleAuthentication
handleAuthentication(email: string, token: string, expiresIn: number, id: number, isGuest: boolean, role?: string, isCont?: boolean)

Call authentication mechanism

Parameters :
Name Type Optional Description
email string No

user email

token string No

user token

expiresIn number No

token expiration

id number No
isGuest boolean No
role string Yes
isCont boolean Yes
Returns : void
Private handleError
handleError(errorRes: any)

Handle authentication errors

Parameters :
Name Type Optional Description
errorRes any No

error responses

Returns : any
login
login(email: string, password: string)

On submit login Dev endpoint: http://localhost:3000/api/authenticate

Parameters :
Name Type Optional Description
email string No

user email

password string No

user password

Returns : any
logout
logout()

Logout from the system but leaves guest account open

Returns : void
removeCredentials
removeCredentials()

Remove user credentials without auto guest login

Returns : void
signup
signup(email: string, password: string, firstname: string, lastname: string, institution?: string, department?: string, role?: string)

Self registration form for SWIM

Parameters :
Name Type Optional Description
email string No

user email

password string No

user password

firstname string No

first name

lastname string No

lastname/surname

institution string Yes

affiliated institution

department string Yes

department affiliated to the institution

role string Yes

user role

Returns : any

Properties

Private tokenExpirationTimer
Type : any

Token expiration timer

user
Default value : new BehaviorSubject<User>(null)

Monitor changes in user information

results matching ""

    No results matching ""