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}",
|
||||
"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,
|
||||
|
@ -1,7 +1,7 @@
|
||||
<adf-login
|
||||
copyrightText="© 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>
|
||||
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user