0.1.6 • Published 6 years ago

@raa/angular-auth v0.1.6

Weekly downloads
-
License
ISC
Repository
github
Last release
6 years ago

angular-auth

Token based authentication module for Angular. Which contains

  • services: AuthenticationService, TokenStorageService
  • guards: AuthGuard
  • interceptors: AuthInterceptor

Installation

Install @raa/angular-auth via npm npm install @raa/angular-auth --save-dev.

Usage

Import AuthenticationService abstract class to extends your AuthService.

@Injectable()
class AuthService extends AuthenticationService {
	protected sendTokenRequest(authenticationModel: AuthenticationModel): Observable<string> {
		return _http.post('http://localhost:5584/api/token', JSON.stringify(authenticationModel))
			map(response => {
				return response.token;
			});
	}
	
}

Import configured AuthModule in your main/core module.

@NgModule({
	imports: [
		AuthModule.configure({
			authenticationService: AuthService,
			fallbackPageUrl: '/login'
		})
	],
	[...]
})
export class CoreModule { }

Inject

@Component({
    selector: 'nav-c',
    templateUrl: './nav.component.html'
})
export class NavComponent implements OnInit {
    constructor(private _authService: AuthenticationService) { }
}

Examples

//todo

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.0

6 years ago