本文整理汇总了TypeScript中app/src/auth/service/auth.service.AuthService类的典型用法代码示例。如果您正苦于以下问题:TypeScript service.AuthService类的具体用法?TypeScript service.AuthService怎么用?TypeScript service.AuthService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了service.AuthService类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(authService: AuthService) {
authService.authenticatedRoute();
}
示例2: signUp
/**
* Signup the user
*/
public signUp(): void {
let email = this._registerForm.value.email;
let password = this._registerForm.value.password;
this._authService.signUp(email, password)
.subscribe(
res => {
if (res.json().token) {
localStorage.setItem('token', res.json().token);
this._router.parent.navigate(['Home']);
} else {
this._registerErrors = 'An error has occured';
}
},
err => {
let body = JSON.parse(err._body);
if (body.message) {
this._registerErrors = body.message;
} else {
this._registerErrors = 'An error has occured';
}
}
);
}
示例3: isLogged
/**
* Check if user is logged
*
* @returns {Boolean} - return if the user is logged
*/
public isLogged() : Boolean {
return this._authService.isLogged();
}
示例4: logout
/**
* User logout
*/
public logout() :void {
this._authService.logout('Home');
}