[英]jHipster - AngularJS route redirects to login even when authorities are removed from entity
By default jHipster generated entities are accessable for ROLE_USER. 默认情况下,jHipster生成的实体可用于ROLE_USER。 I would like to create entity which can be accessible even for unregistred/unauthorized users. 我想创建一个实体,即使是未经注册/未经授权的用户也可以访问。
Let's call the entity: Company 我们将实体称为:公司
What I've done is removal of ROLE_USER from authorities array in every state in company.js. 我所做的是从company.js中每个状态的授权数组中删除ROLE_USER。 I can enter the entity (companys) page by going to http://localhost:3000/#/companys (I can see it for a second) but angular automatically redirects to login view ( http://localhost:3000/#/login ). 我可以通过转到http:// localhost:3000 /#/ companys进入实体(公司)页面(我可以看到一秒钟),但是angular会自动重定向到登录视图( http:// localhost:3000 /#/登录 )。
I believe the behaviour of this routing is somewhere defined in jHipster however I cannot find it. 我相信此路由的行为是在jHipster中定义的,但是我找不到它。 Any hints for angular newbie? 对新手有什么提示吗? :) :)
UPDATED Here is piece of config where I removed authorities: 更新这里是我删除权限的配置部分:
angular.module('testApp')
.config(function ($stateProvider) {
$stateProvider
.state('company', {
parent: 'entity',
url: '/companys',
data: {
authorities: [], <---- here I removed 'ROLE_USER'
pageTitle: 'testApp.company.home.title'
},
views: {
'content@': {
templateUrl: 'scripts/app/entities/company/companys.html',
controller: 'CompanyController'
}
},
resolve: {
translatePartialLoader: ['$translate', '$translatePartialLoader', function ($translate, $translatePartialLoader) {
$translatePartialLoader.addPart('company');
$translatePartialLoader.addPart('companyType');
$translatePartialLoader.addPart('global');
return $translate.refresh();
}]
}
})
Try this way at the com.company.config.SecurityConfiguration
because this will permit all including the unregistered: 在com.company.config.SecurityConfiguration
尝试这种方式,因为这将允许所有包括未注册的:
.disable()
.and()
.authorizeRequests()
.antMatchers("/company/**").permitAll() // <<<<< ADD THIS
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.