0.0.34 • Published 3 years ago

@iodp/iodp-login v0.0.34

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

IODPLogin

This provides a common sign in process for all IODP web applications.

Setup

  1. Install the package:     npm install @iodp/iodp-login         OR     yarn add @iodp/iodp-login

  2. Import IODPLoginModule into your app's Core module:     import { IODPLoginModule } from '@iodp/iodp-login';

    ...     imports:         ...         IODPLoginModule         ...     ,     ...

  1. Navigate to the IODPLoginComponent in your routes:     import { IODPLoginComponent } from '@iodp/iodp-login';

    const routes: Routes =         ...         { path: 'signin', component: IODPLoginComponent },         ...     

  1. Add the AuthGuard to any routes that require a user to be signed in:     import { AuthGuard } from '@iodp/iodp-login';

    const routes: Routes = [         ...         {             path: 'project-templates',             component: ProjectTemplatesComponent,             canActivate: AuthGuard         },         ...     ]

  1. Handle the navigation for after successful sign in. The user will be directed to the 'welcome' url:     const routes: Routes =         ...         { path: 'welcome', pathMatch: 'full', redirectTo: '/project-templates' },         ...     

  2. Include something like the following in your app's startup service:     private _destinationSettings: DestinationObject = {         press F12 to find the needed properties, including if you must select a project     }

    private _encryptSettings: EncryptObject = {         press F12 to find the needed properties     }

    constructor(private login: IODPLoginService) {         this.login.setDestination(this._destinationSettings);         this.login.setEncryption(this._encryptSettings);     }

  1. Use the public properties and methods from IODPLoginService:     import { User, IODPLoginService } from '@iodp/iodp-login';

    project: string     user: User     privileges: string     user$: Subject\()     errors$: Subject\()

    constructor(private login: IODPLoginService) {         this.project = this.login.currentProject         this.user = this.login.currentUser         this.user$ = this.login.user$         this.errors$ = this.login.loginMessage$

        // ONLY NEED TO USE ONE OF THESE         this.privileges = this.login.privileges; // this is synchonous but will not have a value until the login call returns         this.checkPrivilege() // this will asynchonously give you the privileges as soon as they are available     }

    checkPrivilege() {         this.login.privilege.subscribe(resp => {             This contains the user's privileges         })     }

    logout() {         this.login.logout();         this.router.navigate('/signin');     }

0.0.33

3 years ago

0.0.34

3 years ago

0.0.32

3 years ago

0.0.31

3 years ago

0.0.30

3 years ago

0.0.29

3 years ago

0.0.28

3 years ago

0.0.27

3 years ago

0.0.26

3 years ago

0.0.25

3 years ago