From fa14bffc1ceeb6fb26ec756b2f246f6eabc6d596 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Thu, 3 May 2018 12:11:32 +0100 Subject: [PATCH] login enhancements (#343) --- src/app.config.json | 3 +- src/app/components/login/login.component.html | 6 +-- .../components/login/login.component.spec.ts | 37 +++++-------------- src/app/components/login/login.component.ts | 13 +------ 4 files changed, 15 insertions(+), 44 deletions(-) diff --git a/src/app.config.json b/src/app.config.json index 0378eb081..26f08d7ae 100644 --- a/src/app.config.json +++ b/src/app.config.json @@ -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, diff --git a/src/app/components/login/login.component.html b/src/app/components/login/login.component.html index b23521bf6..d6aa3fc8c 100644 --- a/src/app/components/login/login.component.html +++ b/src/app/components/login/login.component.html @@ -1,7 +1,7 @@ + [showLoginActions]="false"> diff --git a/src/app/components/login/login.component.spec.ts b/src/app/components/login/login.component.spec.ts index 18f006a8a..fe4f9a2df 100644 --- a/src/app/components/login/login.component.spec.ts +++ b/src/app/components/login/login.component.spec.ts @@ -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; + 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'); - }); - }); }); diff --git a/src/app/components/login/login.component.ts b/src/app/components/login/login.component.ts index c0e24091e..76aa0f722 100644 --- a/src/app/components/login/login.component.ts +++ b/src/app/components/login/login.component.ts @@ -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'); - } }