Skip to content

Commit

Permalink
revert of "Pull request jhipster#6079 from aleris/angular-typed-roles"
Browse files Browse the repository at this point in the history
polish
  • Loading branch information
deepu105 committed Jul 16, 2017
1 parent f3b731f commit 45f36d0
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 38 deletions.
1 change: 0 additions & 1 deletion generators/client/files-angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ const files = {
{
path: ANGULAR_DIR,
templates: [
'shared/auth/_authorities-constants.ts',
'shared/auth/_csrf.service.ts',
'shared/auth/_state-storage.service.ts',
'shared/auth/_principal.service.ts',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
-%>
import { Route } from '@angular/router';

import { UserRouteAccessService, AuthoritiesConstants } from '../../shared';
import { UserRouteAccessService } from '../../shared';
import { PasswordComponent } from './password.component';

export const passwordRoute: Route = {
path: 'password',
component: PasswordComponent,
data: {
authorities: [AuthoritiesConstants.USER],
authorities: ['ROLE_USER'],
pageTitle: 'global.menu.account.password'
},
canActivate: [UserRouteAccessService]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
-%>
import { Route } from '@angular/router';

import { UserRouteAccessService, AuthoritiesConstants } from '../../shared';
import { UserRouteAccessService } from '../../shared';
import { SessionsComponent } from './sessions.component';

export const sessionsRoute: Route = {
path: 'sessions',
component: SessionsComponent,
data: {
authorities: [AuthoritiesConstants.USER],
authorities: ['ROLE_USER'],
pageTitle: 'global.menu.account.sessions'
},
canActivate: [UserRouteAccessService]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
-%>
import { Route } from '@angular/router';

import { UserRouteAccessService, AuthoritiesConstants } from '../../shared';
import { UserRouteAccessService } from '../../shared';
import { SettingsComponent } from './settings.component';

export const settingsRoute: Route = {
path: 'settings',
component: SettingsComponent,
data: {
authorities: [AuthoritiesConstants.USER],
authorities: ['ROLE_USER'],
pageTitle: 'global.menu.account.settings'
},
canActivate: [UserRouteAccessService]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
limitations under the License.
-%>
import { Routes } from '@angular/router';
import { AuthoritiesConstants } from '../shared';

import {
<%_ if (devDatabaseType !== 'cassandra') { _%>
Expand Down Expand Up @@ -65,7 +64,7 @@ const ADMIN_ROUTES = [
export const adminState: Routes = [{
path: '',
data: {
authorities: [AuthoritiesConstants.ADMIN]
authorities: ['ROLE_ADMIN']
},
canActivate: [UserRouteAccessService],
children: ADMIN_ROUTES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ import { UserMgmtDetailComponent } from './user-management-detail.component';
import { UserDialogComponent } from './user-management-dialog.component';
import { UserDeleteDialogComponent } from './user-management-delete-dialog.component';

import { Principal, AuthoritiesConstants } from '../../shared';
import { Principal } from '../../shared';

@Injectable()
export class UserResolve implements CanActivate {

constructor(private principal: Principal) { }

canActivate() {
return this.principal.identity().then((account) => this.principal.hasAnyAuthority([AuthoritiesConstants.ADMIN]));
return this.principal.identity().then((account) => this.principal.hasAnyAuthority(['ROLE_ADMIN']));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<!-- jhipster-needle-add-entity-to-menu - JHipster will add entities to the menu here -->
</ul>
</li>
<li *<%=jhiPrefix%>HasAnyAuthority="authoritiesConstants.ADMIN" ngbDropdown class="nav-item dropdown pointer" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
<li *<%=jhiPrefix%>HasAnyAuthority="'ROLE_ADMIN'" ngbDropdown class="nav-item dropdown pointer" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">
<a class="nav-link dropdown-toggle" ngbDropdownToggle href="javascript:void(0);" id="admin-menu">
<span>
<i class="fa fa-user-plus" aria-hidden="true"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { Router } from '@angular/router';
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { JhiLanguageService } from 'ng-jhipster';

import { AuthoritiesConstants } from '../../shared';
import { ProfileService } from '../profiles/profile.service';
import { <% if (enableTranslation) { %>JhiLanguageHelper, <% } %>Principal, LoginModalService, LoginService } from '../../shared';

Expand All @@ -40,7 +39,6 @@ import { VERSION, DEBUG_INFO_ENABLED } from '../../app.constants';
})
export class NavbarComponent implements OnInit {

authoritiesConstants = AuthoritiesConstants;
inProduction: boolean;
isNavbarCollapsed: boolean;
languages: any[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
export * from './constants/pagination.constants';
export * from './alert/alert.component';
export * from './alert/alert-error.component';
export * from './auth/authorities-constants';
export * from './auth/csrf.service';
export * from './auth/state-storage.service';
export * from './auth/account.service';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,9 @@ import { Principal } from './principal.service';
*
* @howToUse
* ```
* <some-element *jhiHasAnyAuthority="AuthoritiesConstants.ADMIN">...</some-element>
* <some-element *jhiHasAnyAuthority="'ROLE_ADMIN'">...</some-element>
*
* <some-element *jhiHasAnyAuthority="[AuthoritiesConstants.ADMIN, AuthoritiesConstants.USER]">...</some-element>
* ```
* AuthoritiesConstants needs to be exposed in the component properties accesible from view, add in component:
* ```
* import { AuthoritiesConstants } from '../../shared';
* ...
* authoritiesConstants = AuthoritiesConstants;
* <some-element *jhiHasAnyAuthority="['ROLE_ADMIN', 'ROLE_USER']">...</some-element>
* ```
*/
@Directive({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';

import { User } from './user.model';
import { AuthoritiesConstants } from '../auth/authorities-constants';
import { ResponseWrapper } from '../model/response-wrapper.model';
import { createRequestOption } from '../model/request-util';

Expand Down Expand Up @@ -62,7 +61,7 @@ export class UserService {
return <string[]> json;
});
<%_ } else { _%>
return Observable.of([AuthoritiesConstants.USER, AuthoritiesConstants.ADMIN]);
return Observable.of(['ROLE_USER', 'ROLE_ADMIN']);
<%_ } _%>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ _%>
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes, CanActivate } from '@angular/router';

import { UserRouteAccessService, AuthoritiesConstants, Principal } from '../../shared';
import { UserRouteAccessService } from '../../shared';
import { JhiPaginationUtil } from 'ng-jhipster';

import { <%= entityAngularName %>Component } from './<%= entityFileName %>.component';
Expand Down Expand Up @@ -75,15 +75,15 @@ export const <%= entityInstance %>Route: Routes = [
},
<%_ } _%>
data: {
authorities: [AuthoritiesConstants.USER],
authorities: ['ROLE_USER'],
pageTitle: <% if (enableTranslation){ %>'<%= angularAppName %>.<%= entityTranslationKey %>.home.title'<% }else{ %>'<%= entityClassPlural %>'<% } %>
},
canActivate: [UserRouteAccessService]
}, {
path: '<%= entityUrl %>/:id',
component: <%= entityAngularName %>DetailComponent,
data: {
authorities: [AuthoritiesConstants.USER],
authorities: ['ROLE_USER'],
pageTitle: <% if (enableTranslation){ %>'<%= angularAppName %>.<%= entityTranslationKey %>.home.title'<% }else{ %>'<%= entityClassPlural %>'<% } %>
},
canActivate: [UserRouteAccessService]
Expand All @@ -95,7 +95,7 @@ export const <%= entityInstance %>PopupRoute: Routes = [
path: '<%= entityUrl %>-new',
component: <%= entityAngularName %>PopupComponent,
data: {
authorities: [AuthoritiesConstants.USER],
authorities: ['ROLE_USER'],
pageTitle: <% if (enableTranslation){ %>'<%= angularAppName %>.<%= entityTranslationKey %>.home.title'<% }else{ %>'<%= entityClassPlural %>'<% } %>
},
canActivate: [UserRouteAccessService],
Expand All @@ -105,7 +105,7 @@ export const <%= entityInstance %>PopupRoute: Routes = [
path: '<%= entityUrl %>/:id/edit',
component: <%= entityAngularName %>PopupComponent,
data: {
authorities: [AuthoritiesConstants.USER],
authorities: ['ROLE_USER'],
pageTitle: <% if (enableTranslation){ %>'<%= angularAppName %>.<%= entityTranslationKey %>.home.title'<% }else{ %>'<%= entityClassPlural %>'<% } %>
},
canActivate: [UserRouteAccessService],
Expand All @@ -115,7 +115,7 @@ export const <%= entityInstance %>PopupRoute: Routes = [
path: '<%= entityUrl %>/:id/delete',
component: <%= entityAngularName %>DeletePopupComponent,
data: {
authorities: [AuthoritiesConstants.USER],
authorities: ['ROLE_USER'],
pageTitle: <% if (enableTranslation){ %>'<%= angularAppName %>.<%= entityTranslationKey %>.home.title'<% }else{ %>'<%= entityClassPlural %>'<% } %>
},
canActivate: [UserRouteAccessService],
Expand Down

0 comments on commit 45f36d0

Please sign in to comment.