@iodp/iodp-login
TypeScript icon, indicating that this package has built-in type declarations

0.0.34 • Public • Published

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<User>()     errors$: Subject<string>()

    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']);     }

Readme

Keywords

none

Package Sidebar

Install

npm i @iodp/iodp-login

Weekly Downloads

0

Version

0.0.34

License

none

Unpacked Size

451 kB

Total Files

36

Last publish

Collaborators

  • alekhyabehara
  • timblaisdell
  • menzelr
  • iodpdev
  • sizzlesway22
  • algiemorgan