mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-26 17:24:45 +00:00
login enhancements (#343)
This commit is contained in:
parent
753f0bfb46
commit
fa14bffc1c
@ -2,7 +2,8 @@
|
|||||||
"ecmHost": "http://{hostname}{:port}",
|
"ecmHost": "http://{hostname}{:port}",
|
||||||
"application": {
|
"application": {
|
||||||
"name": "Alfresco Example Content Application",
|
"name": "Alfresco Example Content Application",
|
||||||
"logo": "assets/images/alfresco-logo-white.svg"
|
"logo": "assets/images/alfresco-logo-white.svg",
|
||||||
|
"copyright": "© 2017 - 2018 Alfresco Software, Inc. All rights reserved."
|
||||||
},
|
},
|
||||||
"headerColor": "#2196F3",
|
"headerColor": "#2196F3",
|
||||||
"languagePicker": false,
|
"languagePicker": false,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<adf-login
|
<adf-login
|
||||||
copyrightText="© 2017 - 2018 Alfresco Software, Inc. All rights reserved."
|
[copyrightText]="'application.copyright' | appConfig"
|
||||||
providers="ECM"
|
providers="ECM"
|
||||||
|
successRoute="/personal-files"
|
||||||
[showRememberMe]="false"
|
[showRememberMe]="false"
|
||||||
[showLoginActions]="false"
|
[showLoginActions]="false">
|
||||||
(success)="onLoginSuccess($event)">
|
|
||||||
</adf-login>
|
</adf-login>
|
||||||
|
@ -29,7 +29,7 @@ import { Router } from '@angular/router';
|
|||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
import { TestBed, async } from '@angular/core/testing';
|
import { TestBed, async, ComponentFixture } from '@angular/core/testing';
|
||||||
import {
|
import {
|
||||||
AuthenticationService, UserPreferencesService, TranslationService,
|
AuthenticationService, UserPreferencesService, TranslationService,
|
||||||
TranslationMock, AppConfigService, StorageService, AlfrescoApiService,
|
TranslationMock, AppConfigService, StorageService, AlfrescoApiService,
|
||||||
@ -37,14 +37,14 @@ import {
|
|||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
|
|
||||||
import { LoginComponent } from './login.component';
|
import { LoginComponent } from './login.component';
|
||||||
|
import { AppConfigPipe } from '../../common/pipes/app-config.pipe';
|
||||||
|
|
||||||
describe('LoginComponent', () => {
|
describe('LoginComponent', () => {
|
||||||
let component;
|
let fixture: ComponentFixture<LoginComponent>;
|
||||||
let fixture;
|
let router: Router;
|
||||||
let router;
|
let userPreference: UserPreferencesService;
|
||||||
let userPreference;
|
let auth: AuthenticationService;
|
||||||
let auth;
|
let location: Location;
|
||||||
let location;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@ -54,7 +54,8 @@ describe('LoginComponent', () => {
|
|||||||
RouterTestingModule
|
RouterTestingModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
LoginComponent
|
LoginComponent,
|
||||||
|
AppConfigPipe
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TranslationService, useClass: TranslationMock },
|
{ provide: TranslationService, useClass: TranslationMock },
|
||||||
@ -71,7 +72,6 @@ describe('LoginComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
fixture = TestBed.createComponent(LoginComponent);
|
fixture = TestBed.createComponent(LoginComponent);
|
||||||
component = fixture.componentInstance;
|
|
||||||
|
|
||||||
router = TestBed.get(Router);
|
router = TestBed.get(Router);
|
||||||
location = TestBed.get(Location);
|
location = TestBed.get(Location);
|
||||||
@ -101,23 +101,4 @@ describe('LoginComponent', () => {
|
|||||||
expect(location.forward).toHaveBeenCalled();
|
expect(location.forward).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onLoginSuccess()', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
spyOn(auth, 'isEcmLoggedIn').and.returnValue(false);
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should redirect on success', () => {
|
|
||||||
component.onLoginSuccess();
|
|
||||||
|
|
||||||
expect(router.navigateByUrl).toHaveBeenCalledWith('/personal-files');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set user preference store prefix', () => {
|
|
||||||
component.onLoginSuccess({ username: 'bogus' });
|
|
||||||
|
|
||||||
expect(userPreference.setStoragePrefix).toHaveBeenCalledWith('bogus');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -25,18 +25,15 @@
|
|||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
import { Router } from '@angular/router';
|
import { AuthenticationService } from '@alfresco/adf-core';
|
||||||
import { AuthenticationService, UserPreferencesService } from '@alfresco/adf-core';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './login.component.html'
|
templateUrl: './login.component.html'
|
||||||
})
|
})
|
||||||
export class LoginComponent implements OnInit {
|
export class LoginComponent implements OnInit {
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
|
||||||
private location: Location,
|
private location: Location,
|
||||||
private auth: AuthenticationService,
|
private auth: AuthenticationService,
|
||||||
private userPreferences: UserPreferencesService
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -44,12 +41,4 @@ export class LoginComponent implements OnInit {
|
|||||||
this.location.forward();
|
this.location.forward();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoginSuccess(data) {
|
|
||||||
if (data && data.username) {
|
|
||||||
this.userPreferences.setStoragePrefix(data.username);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.router.navigateByUrl('/personal-files');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user