Skip to content

Commit

Permalink
Merge pull request #7 from guillotinaweb/wip_login
Browse files Browse the repository at this point in the history
Login
  • Loading branch information
ebrehault authored Feb 20, 2020
2 parents 5ea28ad + 9993b19 commit 01c22f6
Show file tree
Hide file tree
Showing 10 changed files with 518 additions and 225 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.1.0 (2020-02-20)

- Support full login logic (bloodbare)

# 1.0.3 (2020-01-24)

- Auto-tagging and auto-release to NPM
Expand Down
4 changes: 2 additions & 2 deletions projects/grange-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@guillotinaweb/grange-core",
"version": "1.0.3",
"name": "grange-core",
"version": "1.1.0",
"license": "MIT",
"author": {
"name": "Eric Brehault",
Expand Down
1 change: 1 addition & 0 deletions projects/grange-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export { GrangeCore } from './lib/core.service';
export { APIService } from './lib/api.service';
export { AuthenticationService } from './lib/authentication.service';
export { CacheService } from './lib/cache.service';
export { ReCaptchaV3Service } from './lib/recaptcha_v3.service';
export { ConfigurationService } from './lib/configuration.service';
export * from './lib/loading.service';
export * from './lib/resource.service';
Expand Down
3 changes: 2 additions & 1 deletion projects/grange-core/src/lib/api.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ describe('APIService', () => {
{
provide: 'CONFIGURATION', useValue: {
BACKEND_URL: 'http://fake/Plone',
}}
}},
{ provide: 'LANG', useValue: 'en'},
]
});

Expand Down
11 changes: 7 additions & 4 deletions projects/grange-core/src/lib/authentication.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { HttpErrorResponse, HttpEventType, HttpHeaders } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { TestBed, async } from '@angular/core/testing';
import { AuthenticatedStatus, Error, PasswordResetInfo } from './interfaces';
import { AuthenticationService, getError } from './authentication.service';
import { ConfigurationService } from './configuration.service';
import { ReCaptchaV3Service } from './recaptcha_v3.service';
import { filter } from 'rxjs/operators';

describe('AuthenticationService', () => {
beforeEach(() => {
Expand All @@ -12,11 +14,13 @@ describe('AuthenticationService', () => {
providers: [
AuthenticationService,
ConfigurationService,
ReCaptchaV3Service,
{
provide: 'CONFIGURATION', useValue: {
BACKEND_URL: 'http://fake/Plone',
}
},
{ provide: 'LANG', useValue: 'en'},
]
});
});
Expand Down Expand Up @@ -89,15 +93,14 @@ describe('AuthenticationService', () => {
});

it('should logout', () => {
const service = TestBed.get(AuthenticationService);
const service: AuthenticationService = TestBed.get(AuthenticationService);

// fake login
localStorage.setItem('auth', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiZnVsbG5hbWUiOiJGb28gYmFyIiwiZ' +
'XhwaXJlcyI6MTQ2NjE0MDA2Ni42MzQ5ODYsInR5cGUiOiJKV1QiLCJhbGdvcml0aG0iOiJIUzI1NiJ9.D9EL5A9xD1z3E_HPecXA-Ee7kKlljYvpDtan69KHwZ8');
localStorage.setItem('auth_time', (new Date()).toISOString());

service.logout();

service._logout();
expect(localStorage.getItem('auth')).toEqual(null);
expect(localStorage.getItem('auth_time')).toEqual(null);
});
Expand Down
Loading

0 comments on commit 01c22f6

Please sign in to comment.