У меня проблема, когда я выхожу по почте, чтобы выйти до конца весны, я получил статус 302 о перенаправлении на вход в систему? Выход, но я не могу отобразить эту страницу.
Я использую весеннюю конфигурацию HttpSecurity по умолчанию, за исключением того, что я отключил csrf.
Что я делаю неправильно, пожалуйста?
Мой весенний конфиг HttpSecurity:
@Configuration
protected static class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.anyRequest().authenticated()
.and()
.formLogin()
.and()
.logout();
}
}
Мой шаблон app.component.html .
<header>
<div id="logo">
<h1>Clinical</h1>
<h1>Questionnaire</h1>
</div>
<div id="logout" (click)="logout()">
<span>Log out</span><i class="icon glyphicon glyphicon-off"></i>
</div>
</header>
<aside>
<nav>
<ul>
<li class="static">Menu</li>
<li>
<a routerLink="/forms" routerLinkActive="active"><i class="glyphicon glyphicon-list-alt"></i>Test Forms</a>
</li>
</ul>
</nav>
</aside>
<div class="content-wrapper">
<router-outlet></router-outlet>
</div>
Моя логика компонента app.component.ts
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.less']
})
export class AppComponent {
title = 'app';
constructor(private appService: AppService, private router: Router) {}
logout() {
this.appService.logout().finally(() => {
this.router.navigateByUrl('/login?logout');
}).subscribe(msg => {
console.log(msg);
});
}
}
My app.service.ts
@Injectable()
export class AppService {
/**
* Address of server.
*/
private static url: string;
/**
* Rest api address for test forms.
*/
private static logoutUrl: string;
constructor(private http: HttpClient) {
const api = environment.api;
AppService.url = `${api.protocol}://${api.ip}:${api.port}`;
AppService.logoutUrl = `${AppService.url}/logout`;
}
logout(): Observable<Object> {
return this.http.post(AppService.logoutUrl, {});
}
}
My app.routing.module.ts
const ROUTES: Routes = [
{path: '', redirectTo: '/forms', pathMatch: 'full'},
{path: 'formBuilder/:uuid/:name', loadChildren: 'app/forms/formBuilder/form-builder.module#FormBuilderModule'},
{path: '**', component: PageNotFoundComponent}
];
@NgModule({
imports: [RouterModule.forRoot(ROUTES)],
exports: [RouterModule]
})
export class AppRoutingModule {
}