Authentication JHipster:登录成功后如何重定向到另一个页面?

Authentication JHipster:登录成功后如何重定向到另一个页面?,authentication,redirect,login,jhipster,Authentication,Redirect,Login,Jhipster,试图更改JHipster default application gateway的默认行为,我正在寻找重定向到自定义login_success.html页面的正确方法。是否有任何官方教程或解决方法 我尝试了如下操作,但是没有任何效果,在login.component.ts中编辑login函数;甚至没有错误: login() { this.loginService.login({ username: this.username, password: this

试图更改JHipster default application gateway的默认行为,我正在寻找重定向到自定义login_success.html页面的正确方法。是否有任何官方教程或解决方法

我尝试了如下操作,但是没有任何效果,在login.component.ts中编辑login函数;甚至没有错误:

login() {
    this.loginService.login({
        username: this.username,
        password: this.password,
        rememberMe: this.rememberMe
    }).then(() => {
        this.authenticationError = false;
        this.activeModal.dismiss('login success');
        if (this.router.url === '/register' || (/^\/activate\//.test(this.router.url)) ||
            (/^\/reset\//.test(this.router.url))) {
            this.router.navigate(['']);
        }

        this.eventManager.broadcast({
            name: 'authenticationSuccess',
            content: 'Sending Authentication Success'
        });

        // // previousState was set in the authExpiredInterceptor before being redirected to login modal.
        // // since login is succesful, go to stored previousState and clear previousState
        // const redirect = this.stateStorageService.getUrl();
        const redirect = '/something.html';
        console.log('Before Redirect');
        if (redirect) {
            console.log('Redirect');
            this.stateStorageService.storeUrl(null);
            // this.router.navigate([redirect]);
            this.router.navigateByUrl(redirect);
        }
    }).catch(() => {
        this.authenticationError = true;
    });
}

在login.component.ts中查找:

        // // previousState was set in the authExpiredInterceptor before being redirected to login modal.
        // // since login is succesful, go to stored previousState and clear previousState
        const redirect = this.stateStorageService.getUrl();
        if (redirect) {
            this.stateStorageService.storeUrl(null);
            this.router.navigate([redirect]);
        }
并改为:

        // // previousState was set in the authExpiredInterceptor before being redirected to login modal.
        // // since login is succesful, go to stored previousState and clear previousState
        const redirect = this.stateStorageService.getUrl();
        if (redirect) {
            this.stateStorageService.storeUrl(null);
            this.router.navigate([redirect]);
        } else {
            this.stateStorageService.storeUrl(null);
            this.router.navigate(['/panel']);
        }

其中“/panel”是要重定向的页面。

在login.component.ts中查找:

        // // previousState was set in the authExpiredInterceptor before being redirected to login modal.
        // // since login is succesful, go to stored previousState and clear previousState
        const redirect = this.stateStorageService.getUrl();
        if (redirect) {
            this.stateStorageService.storeUrl(null);
            this.router.navigate([redirect]);
        }
并改为:

        // // previousState was set in the authExpiredInterceptor before being redirected to login modal.
        // // since login is succesful, go to stored previousState and clear previousState
        const redirect = this.stateStorageService.getUrl();
        if (redirect) {
            this.stateStorageService.storeUrl(null);
            this.router.navigate([redirect]);
        } else {
            this.stateStorageService.storeUrl(null);
            this.router.navigate(['/panel']);
        }

其中“/panel”是您要重定向的页面。

我使用的是JWT令牌如果您要重定向到与index.html不同的静态html页面,那么这将比使用路由停留在同一角度的应用程序中更复杂。我宁愿调整JHipster的工作,而不是围绕它工作。好吧,这个想法就是简单地将用户重定向到它的个人信息页面。因此,例如,有两种情况:1-用户是管理员-->登录-->监控人员2-普通用户-->登录-->个人信息页面根据用户的角色提供一些新路由是否更容易获得此信息?这是一个角度路由,它应该使用其模板指向角度组件。我建议您了解更多有关角度布线和组件的信息,如果你想重定向到一个不同于index.html的静态html页面,这将比使用路由的同一角度应用程序更复杂。我宁愿调整JHipster的工作,而不是围绕它工作。好吧,这个想法就是简单地将用户重定向到它的个人信息页面。因此,例如,有两种情况:1-用户是管理员-->登录-->监控人员2-普通用户-->登录-->个人信息页面根据用户的角色提供一些新路由是否更容易获得此信息?这是一个角度路由,它应该使用其模板指向角度组件。我建议你学习更多关于角度布线和组件的知识,没有基础你将一事无成。我建议你删除这个问题,因为它不会帮助任何人