Skip to content

Commit

Permalink
Merge pull request #5 from xetys/ng2-uaa
Browse files Browse the repository at this point in the history
auth expired interceptor
  • Loading branch information
sendilkumarn authored Nov 17, 2016
2 parents a16e838 + fe9d896 commit 8464372
Show file tree
Hide file tree
Showing 112 changed files with 848 additions and 381 deletions.
6 changes: 4 additions & 2 deletions generators/client-2/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ const files = {
'_app.ng2module.ts',
'_app.state.ts',
'_app.constants.ts',
'blocks/handlers/_state.handler.ts',
'blocks/config/_register-transition-hooks.ts',
'blocks/config/_router.config.ts',
'blocks/config/_http.config.ts',
'blocks/config/_localstorage.config.ts',
'blocks/config/_compile.config.ts',
'blocks/config/_uib-pager.config.ts',
'blocks/config/_uib-pagination.config.ts',
'blocks/config/_ui-router-defer-intercept.config.ts',
//interceptors
'blocks/interceptor/_auth-expired.interceptor.ts',
'blocks/interceptor/_errorhandler.interceptor.ts',
Expand Down Expand Up @@ -142,6 +142,8 @@ const files = {
'layouts/profiles/_profile.service.ts',
'layouts/profiles/_profile-info.model.ts',
'layouts/profiles/_page-ribbon.component.ts',
'layouts/main/_main.component.ts',
'layouts/main/_main.html',
'layouts/navbar/_navbar.component.ts',
{ file: 'layouts/navbar/_navbar.html', method: 'copyHtml' },
'layouts/footer/_footer.component.ts',
Expand Down
3 changes: 1 addition & 2 deletions generators/client-2/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
"@angular/platform-browser-dynamic": "2.0.1",
"@angular/upgrade": "2.0.1",
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.10",
"angular-ui-router": "1.0.0-beta.3",
"core-js": "2.4.1",
"jquery": "3.1.0",
"angular2-cookie": "1.2.5",
<%_ if (enableTranslation){ _%>
"ng2-translate": "3.1.1",
<%_ } _%>
"ng2-webstorage": "1.3.0",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.27",
"ui-router-ng1-to-ng2": "1.0.15",
"ui-router-ng2": "1.0.0-beta.3",
"ui-router-visualizer": "2.0.11",
"zone.js": "0.6.23"
Expand Down
1 change: 1 addition & 0 deletions generators/client-2/templates/gulp/_copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function deps(){
'node_modules/ui-router-ng1-to-ng2/**/*.js',
'node_modules/ui-router-ng2/**/*.js',
'node_modules/ui-router-visualizer/**/*.js',
'node_modules/angular2-cookie/**/*.js',
'node_modules/ng2-webstorage/bundles/**/*.js',
<%_ if(enableTranslation) { _%>
'node_modules/ng2-translate/bundles/ng2-translate.js',
Expand Down
15 changes: 6 additions & 9 deletions generators/client-2/templates/src/main/webapp/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<meta name="google" value="notranslate">
<%_ } _%>
<meta name="viewport" content="width=device-width">
<base href="/"/>
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css content/css/vendor.css -->
<!-- bower:css -->
Expand All @@ -25,12 +26,11 @@
<!--[if lt IE 9]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<page-ribbon></page-ribbon>
<div ui-view="navbar" ng-cloak></div>
<<%=jhiPrefix%>-main></<%=jhiPrefix%>-main>
<!-- inject:troubleshoot -->
<!-- This content is for troubleshooting purpose and will be removed by `gulp install` task -->
<div class="container">
<div class="well" ui-view="content">
<!-- inject:troubleshoot -->
<!-- This content is for troubleshooting purpose and will be removed by `gulp install` task -->
<div class="well">
<h1>An error has occured :-(</h1>
<i>There was an error when generating this application with <a href="http://jhipster.github.io/">JHipster</a></i>
<p>If you are seeing this, it means something went wrong during the initial setup of the application.</p>
Expand Down Expand Up @@ -72,12 +72,9 @@ <h3>If you want to chat with contributors and other users</h3>
<p>
Join our chat room on <a href="https://gitter.im/jhipster/generator-jhipster" target="_blank">Gitter.im</a>. Please note that this is a public chat room, and that we expect you to respect other people and write in a correct English language!
</p>
<!-- endinject -->
</div>

<footer></footer>
</div>

<!-- endinject -->
<!-- Google Analytics: uncomment and change UA-XXXXX-X to be your site's ID.
<script>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'ui-router-ng1-to-ng2': 'vendor/ui-router-ng1-to-ng2/ng1-to-ng2.js',
'ui-router-visualizer': 'vendor/ui-router-visualizer/release/visualizer.min.js',
'jquery' : 'vendor/jquery/dist',
'angular2-cookie': 'vendor/angular2-cookie',
'ng2-webstorage': 'vendor/ng2-webstorage',
<%_ if (enableTranslation){ _%>
'ng2-translate': 'vendor/ng2-translate/bundles',
Expand All @@ -36,6 +37,7 @@
'@ng-bootstrap/ng-bootstrap': { main: '/bundles/ng-bootstrap', defaultExtension: 'js' },
'ui-router-ng2': {},
'jquery': { main: 'jquery.min', defaultExtension: 'js' },
'angular2-cookie': {main: 'index', defaultExtension: 'js'},
'ng2-webstorage': { main: 'bundles/core.umd.js', defaultExtension: 'js' },
<%_ if (enableTranslation){ _%>
'ng2-translate': {main: 'ng2-translate', defaultExtension: 'js'},
Expand Down
23 changes: 7 additions & 16 deletions generators/client-2/templates/src/main/webapp/app/_app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@ import './entities/entity.module';
import { upgradeAdapter } from './upgrade_adapter';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';

import { StateHandler } from './blocks/handlers/state.handler';<% if (enableTranslation) { %>
import { VERSION } from "./app.constants";<% if (enableTranslation) { %>

import { TranslationConfig } from './blocks/config/translation.config';
import { TranslationStorageProvider } from './blocks/config/translation-storage.provider';<% } %>
import { UIRouterDeferInterceptConfig } from './blocks/config/ui-router-defer-intercept.config';

import { CompileServiceConfig } from './blocks/config/compile.config';
import { HttpConfig } from './blocks/config/http.config';
import { PagerConfig } from './blocks/config/uib-pager.config';
import { PaginationConfig } from './blocks/config/uib-pagination.config';

import { HomeComponent } from './home';
import { NavbarComponent, FooterComponent, PageRibbonComponent } from './layouts';
import { <%=jhiPrefixCapitalized%>MainComponent, NavbarComponent, FooterComponent, PageRibbonComponent } from './layouts';

import { AuthExpiredInterceptor } from './blocks/interceptor/auth-expired.interceptor';
import { ErrorHandlerInterceptor } from './blocks/interceptor/errorhandler.interceptor';
import { NotificationInterceptor } from './blocks/interceptor/notification.interceptor';

Expand All @@ -36,7 +34,6 @@ angular
'ngCacheBuster',
'ngFileUpload',
'ui.bootstrap',
'ui.router.upgrade',
'infinite-scroll',
'angular-loading-bar',
// jhipster-needle-angularjs-add-module JHipster will add new module here
Expand All @@ -48,26 +45,20 @@ angular
.config(HttpConfig)
.config(PagerConfig)
.config(PaginationConfig)
.config(UIRouterDeferInterceptConfig)
.directive('<%=jhiPrefix%>LoginModal', <angular.IDirectiveFactory> upgradeAdapter.downgradeNg2Component(<%=jhiPrefixCapitalized%>LoginModalComponent))
.directive('home', <angular.IDirectiveFactory> upgradeAdapter.downgradeNg2Component(HomeComponent))
.directive('navbar', <angular.IDirectiveFactory> upgradeAdapter.downgradeNg2Component(NavbarComponent))
.directive('footer', <angular.IDirectiveFactory> upgradeAdapter.downgradeNg2Component(FooterComponent))
.factory('AuthExpiredInterceptor', AuthExpiredInterceptor)
.directive('<%=jhiPrefix%>Main', <angular.IDirectiveFactory> upgradeAdapter.downgradeNg2Component(<%=jhiPrefixCapitalized%>MainComponent))
.factory('ErrorHandlerInterceptor', ErrorHandlerInterceptor)
.factory('NotificationInterceptor', NotificationInterceptor)
.factory('StateHandler',StateHandler)<% if (enableTranslation) { %>
.factory('NotificationInterceptor', NotificationInterceptor)<% if (enableTranslation) { %>
.factory('TranslationStorageProvider', TranslationStorageProvider)
.config(TranslationConfig)<% } %>
<%_ if (websocket === 'spring-websocket') { _%>
.factory('TrackerService', upgradeAdapter.downgradeNg2Provider(<%=jhiPrefixCapitalized%>TrackerService))
<%_ } _%>
.directive('pageRibbon', <angular.IDirectiveFactory> upgradeAdapter.downgradeNg2Component(PageRibbonComponent))
.factory('NgbModal', upgradeAdapter.downgradeNg2Provider(NgbModal))
.run(run);

run.$inject = ['StateHandler'];
run.$inject = ['$rootScope'];

function run(StateHandler) {
StateHandler.initialize();
function run($rootScope) {
$rootScope.VERSION = VERSION;
}
51 changes: 37 additions & 14 deletions generators/client-2/templates/src/main/webapp/app/_app.ng2module.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<%_ if(authenticationType === 'uaa') { _%>
import { AuthInterceptor } from './blocks/interceptor/auth.interceptor';
<%_ } %>
import { NgModule } from '@angular/core';
import { NgModule, Injector } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { Http, Request, RequestOptionsArgs, RequestOptions, XHRBackend } from '@angular/http';
import { UIRouterModule } from 'ui-router-ng2';
import { Ng1ToNg2Module } from 'ui-router-ng1-to-ng2';
import { UIRouterModule, RootModule } from 'ui-router-ng2';
<%_ if (authenticationType === 'oauth2' || authenticationType === 'jwt' || authenticationType === 'uaa') { _%>
import { Ng2Webstorage, LocalStorageService, SessionStorageService } from 'ng2-webstorage';
<%_ } if(authenticationType === 'session') { _%>
import { Ng2Webstorage } from 'ng2-webstorage';
<% } %>

import { <%=angular2AppName%>SharedModule } from './shared';
import { <%=angular2AppName%>AdminModule } from './admin/admin.ng2module'; //TODO these couldnt be used from barrels due to an error
import { <%=angular2AppName%>AccountModule } from './account/account.ng2module';

import { appState } from './app.state';
import { HomeComponent, homeState } from './home';
import { <%=jhiPrefixCapitalized%>RouterConfig } from './blocks/config/router.config';
import {
<%=jhiPrefixCapitalized%>MainComponent,
NavbarComponent,
FooterComponent,
ProfileService,
Expand All @@ -28,11 +32,19 @@ import {
} from './layouts';
import { localStorageConfig } from './blocks/config/localstorage.config';
import { HttpInterceptor } from './blocks/interceptor/http.interceptor';
import {AuthExpiredInterceptor} from "./blocks/interceptor/auth-expired.interceptor";
<%_ if (authenticationType === 'oauth2' || authenticationType === 'jwt' || authenticationType === 'uaa') { _%>
import {Http, XHRBackend, RequestOptions} from "@angular/http";
<%_ } if(authenticationType === 'session') { _%>
import { StateStorageService } from "./shared/auth/state-storage.service";
<% } %>



localStorageConfig();

let routerConfig = {
configClass: <%=jhiPrefixCapitalized%>RouterConfig,
otherwise: '/',
states: [
appState,
Expand All @@ -45,20 +57,22 @@ let routerConfig = {
@NgModule({
imports: [
BrowserModule,
UIRouterModule.forRoot(routerConfig),
Ng2Webstorage,
Ng1ToNg2Module,
UIRouterModule.forChild(routerConfig),
<%=angular2AppName%>SharedModule,
<%=angular2AppName%>AdminModule,
<%=angular2AppName%>AccountModule
],
declarations: [
<%=jhiPrefixCapitalized%>MainComponent,
HomeComponent,
NavbarComponent,
ErrorComponent,
PageRibbonComponent,
FooterComponent<% if (enableTranslation){ %>,
ActiveMenuDirective<% } %>
<%_ if (enableTranslation){ _%>
ActiveMenuDirective,
<%_ } _%>
FooterComponent
],
providers: [
ProfileService,
Expand All @@ -69,30 +83,39 @@ let routerConfig = {
useFactory: (
backend: XHRBackend,
defaultOptions: RequestOptions,
<%_ if(authenticationType === 'uaa') { _%>
<%_ if (authenticationType === 'oauth2' || authenticationType === 'jwt' || authenticationType === 'uaa') { _%>
localStorage : LocalStorageService,
sessionStorage : SessionStorageService
sessionStorage : SessionStorageService,
injector
<%_ } if (authenticationType === 'session') { _%>
injector
<%_ } _%>
) => new HttpInterceptor(
backend,
defaultOptions,
[
<%_ if(authenticationType === 'uaa') { _%>
new AuthInterceptor(localStorage, sessionStorage)
<%_ if (authenticationType === 'oauth2' || authenticationType === 'jwt' || authenticationType === 'uaa') { _%>
new AuthInterceptor(localStorage, sessionStorage),
new AuthExpiredInterceptor(injector)
<%_ } if (authenticationType === 'session') { _%>
new AuthExpiredInterceptor(injector, injector.get("$rootScope"), stateStorageService)
<%_ } _%>
//other intecetpors can be added here
]
),
deps: [
XHRBackend,
RequestOptions,
<%_ if(authenticationType === 'uaa') { _%>
Injector,
<%_ if (authenticationType === 'oauth2' || authenticationType === 'jwt' || authenticationType === 'uaa') { _%>
LocalStorageService,
SessionStorageService
<%_ } if (authenticationType === 'session') { _%>
StateStorageService
<%_ } _%>
]
}
],
bootstrap: [ HomeComponent ]
bootstrap: [ <%=jhiPrefixCapitalized%>MainComponent ]
})
export class <%=angular2AppName%>AppModule {}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { UpgradeAdapter } from '@angular/upgrade';
import { uiRouterNgUpgrade } from 'ui-router-ng1-to-ng2';
import { forwardRef } from '@angular/core';
import { <%=angular2AppName%>AppModule } from './app.ng2module';

export var upgradeAdapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => <%=angular2AppName%>AppModule));
uiRouterNgUpgrade.setUpgradeAdapter(upgradeAdapter);
upgradeAdapter.upgradeNg1Provider('$stateParams');
upgradeAdapter.upgradeNg1Provider('$uibModal');
upgradeAdapter.upgradeNg1Provider('$state');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ angular
'tmh.dynamicLocale',
<%_ } _%>
'ngResource',
'ui.bootstrap',
'ui.router'
'ui.bootstrap'
])
<%_ if (enableSocialSignIn) { _%>
<%_ if (authenticationType == 'jwt') { _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
<div class="col-md-8 col-md-offset-2">
<h1 translate="activate.title">Activation</h1>

<div class="alert alert-success" *ngIf="success" translate="activate.messages.success" translate-compile>
<strong>Your user has been activated.</strong> Please <a class="alert-link" (click)="login()">sign in</a>.
<div class="alert alert-success" *ngIf="success">
<span jhi-translate="activate.messages.success">
<strong>Your user has been activated.</strong> Please
<a class="alert-link" (click)="login()" jhi-translate="global.messages.info.authenticated.link">sign in</a>.
</span>
</div>

<div class="alert alert-danger" *ngIf="error" translate="activate.messages.error">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ <h1 translate="reset.finish.title">Reset password</h1>
<p translate="reset.finish.messages.error">Your password couldn't be reset. Remember a password request is only valid for 24 hours.</p>
</div>

<div class="alert alert-success" *ngIf="success">
<p translate="reset.finish.messages.success" translate-compile><strong>Your password has been reset.</strong> Please <a class="alert-link" (click)="login()">sign in</a>.</p>
</div>
<p class="alert alert-success" *ngIf="success">
<span translate="reset.finish.messages.success"><strong>Your password has been reset.</strong> Please </span>
<a class="alert-link" (click)="login()" translate="global.messages.info.authenticated.link">sign in</a>.
</p>

<div class="alert alert-danger" *ngIf="doNotMatch" translate="global.messages.error.dontmatch">
The password and its confirmation do not match!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1 translate="register.title">Registration</h1>
<form name="form" role="form" (ngSubmit)="register()" #registerForm="ngForm">
<div class="form-group">
<label class="control-label" for="login" translate="global.form.username">Username</label>
<input type="text" class="form-control" [(ngModel)]="registerAccount.login" id="login" name="login" #login="ngModel" placeholder="{{'global.form.login.placeholder' | translate}}"
<input type="text" class="form-control" [(ngModel)]="registerAccount.login" id="login" name="login" #login="ngModel" placeholder="{{'global.form.username.placeholder' | translate}}"
required minlength="1" maxlength="50" pattern="^[_'.@A-Za-z0-9-]*$">
<div *ngIf="login.dirty && login.invalid">
<p class="help-block" *ngIf="login.errors.required" translate="register.messages.validate.login.required">
Expand Down Expand Up @@ -117,8 +117,9 @@ <h1 translate="register.title">Registration</h1>
<button type="submit" [disabled]="registerForm.form.invalid" class="btn btn-primary" translate="register.form.button">Register</button>
</form>
<p></p>
<div class="alert alert-warning" translate="global.messages.info.authenticated" translate-compile>
If you want to <a class="alert-link" (click)="openLogin()">sign in</a>, you can try the default accounts:<br/>- Administrator (login="admin" and password="admin") <br/>- User (login="user" and password="user").
<div class="alert alert-warning">
<span jhi-translate="global.messages.info.authenticated.prefix">If you want to </span>
<a class="alert-link" (click)="openLogin()" jhi-translate="global.messages.info.authenticated.link">sign in</a><span jhi-translate="global.messages.info.authenticated.suffix">, you can try the default accounts:<br/>- Administrator (login="admin" and password="admin") <br/>- User (login="user" and password="user").</span>
</div>
</div>
<%_ if (enableSocialSignIn) { _%>
Expand Down
Loading

0 comments on commit 8464372

Please sign in to comment.