1.1.4 • Published 5 years ago

@invsqr/auth v1.1.4

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

Installation

Using npm:

npm install @invsqr/auth --save

Setup

In your root module (e.g. AppModule):

import { AuthModule, AuthService } from "auth";

@NgModule({
	declarations: [
		...
	],
	imports: [
		...
		AuthModule.forRoot({ apiUrl: "...", passwordResetRoute: "...", emailConfirmRoute: "..." })
	],
	providers: [
		...
		AuthService
	],
	bootstrap: [...]
})
export class AppModule { }

AuthModule.forRoot could, for instance, accept the application's environment file, assuming the environment file contains apiUrl, passwordResetRoute and emailConfirmRoute properties

Usage

Login

In your login template:

...
	<input type="email" fdnUsername>

	<input type="password" fdnPassword>

	<button type="submit" fdnSubmit [submitMode]="SubmitMode.Login" (complete)="submitComplete($event)">Submit</button>
...

fdnUsername binds the email input's value to the AuthService, while fdnPassword binds to the password input, which get submitted for login when click is detected on the fdnSubmit button

Other

See SubmitMode enum for all available submit operations, and the corresponding AuthService public methods for usage guidelines

enum SubmitMode {
	/** POST username and password for login */
	Login,
	/** POST username, email and password for new account */
	Register,
	/** GET password reset email */
	GetReset,
	/** PUT reset token and password for new password */
	PutReset,
	/** PUT password for new password */
	ChangePassword
}

Configuration

The AuthModule.forRoot should accept an object with project-specific configuration settings

  • apiUrl - the root URL of the application API
  • passwordResetRoute - the route that the password reset email will direct the user to and should accept the following path parameters: email - the user's email address, to pre-populate and prevent them from having to enter themselves code - the password reset token that should be included in the PUT request to submit the new password
  • emailConfirmRoute - the route that the email confirmation will direct the user to and should accept the following path parameters: userId - the user's id; pass this to the AuthService's parameter of the same name code - the email confirmation token that should be included in the GET request to confirm the user's email address

Notes

While input validation is left to the devices of the consumer (at least for now), Angular's Reactive Forms are stongly encouraged.

1.1.4

5 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago