login enhancements (#343)

This commit is contained in:
Denys Vuika 2018-05-03 12:11:32 +01:00 committed by Cilibiu Bogdan
parent 753f0bfb46
commit fa14bffc1c
4 changed files with 15 additions and 44 deletions

View File

@ -2,7 +2,8 @@
"ecmHost": "http://{hostname}{:port}",
"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",
"languagePicker": false,

View File

@ -1,7 +1,7 @@
<adf-login
copyrightText="&#169; 2017 - 2018 Alfresco Software, Inc. All rights reserved."
[copyrightText]="'application.copyright' | appConfig"
providers="ECM"
successRoute="/personal-files"
[showRememberMe]="false"
[showLoginActions]="false"
(success)="onLoginSuccess($event)">
[showLoginActions]="false">
</adf-login>

View File

@ -29,7 +29,7 @@ import { Router } from '@angular/router';
import { HttpClientModule } from '@angular/common/http';
import { TranslateModule } from '@ngx-translate/core';
import { Location } from '@angular/common';
import { TestBed, async } from '@angular/core/testing';
import { TestBed, async, ComponentFixture } from '@angular/core/testing';
import {
AuthenticationService, UserPreferencesService, TranslationService,
TranslationMock, AppConfigService, StorageService, AlfrescoApiService,
@ -37,14 +37,14 @@ import {
} from '@alfresco/adf-core';
import { LoginComponent } from './login.component';
import { AppConfigPipe } from '../../common/pipes/app-config.pipe';
describe('LoginComponent', () => {
let component;
let fixture;
let router;
let userPreference;
let auth;
let location;
let fixture: ComponentFixture<LoginComponent>;
let router: Router;
let userPreference: UserPreferencesService;
let auth: AuthenticationService;
let location: Location;
beforeEach(async(() => {
TestBed.configureTestingModule({
@ -54,7 +54,8 @@ describe('LoginComponent', () => {
RouterTestingModule
],
declarations: [
LoginComponent
LoginComponent,
AppConfigPipe
],
providers: [
{ provide: TranslationService, useClass: TranslationMock },
@ -71,7 +72,6 @@ describe('LoginComponent', () => {
});
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
router = TestBed.get(Router);
location = TestBed.get(Location);
@ -101,23 +101,4 @@ describe('LoginComponent', () => {
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');
});
});
});

View File

@ -25,18 +25,15 @@
import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
import { Router } from '@angular/router';
import { AuthenticationService, UserPreferencesService } from '@alfresco/adf-core';
import { AuthenticationService } from '@alfresco/adf-core';
@Component({
templateUrl: './login.component.html'
})
export class LoginComponent implements OnInit {
constructor(
private router: Router,
private location: Location,
private auth: AuthenticationService,
private userPreferences: UserPreferencesService
) {}
ngOnInit() {
@ -44,12 +41,4 @@ export class LoginComponent implements OnInit {
this.location.forward();
}
}
onLoginSuccess(data) {
if (data && data.username) {
this.userPreferences.setStoragePrefix(data.username);
}
this.router.navigateByUrl('/personal-files');
}
}