Merge Request #12
Login block
Added the Noosfero basic login-block.
-
Merge remote-tracking branch 'origin/master' into login-block
- 8 of 9 commits displayed. Click here to show all
@@ -0,0 +1,110 @@ | @@ -0,0 +1,110 @@ | ||
1 | +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; | ||
2 | +import {Injectable, Provider, provide} from "ng-forward"; | ||
3 | +import {ComponentTestHelper, createClass} from './../../../../spec/component-test-helper'; | ||
4 | +import {ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder'; | ||
5 | +import {providers} from 'ng-forward/cjs/testing/providers'; | ||
6 | +import {LoginBlockComponent} from './login-block.component'; | ||
7 | +import * as helpers from "./../../../../spec/helpers"; | ||
8 | +import {SessionService, AuthService, AuthController, AuthEvents} from "./../../../login"; | ||
9 | + | ||
10 | +const htmlTemplate: string = '<noosfero-login-block></noosfero-login-block>'; | ||
11 | + | ||
12 | +describe("Components", () => { | ||
13 | + | ||
14 | + describe("Login Block Component", () => { | ||
15 | + let helper: ComponentTestHelper<LoginBlockComponent>; | ||
16 | + let person: any = null; | ||
17 | + | ||
18 | + /** | ||
19 | + * Mock objects | ||
20 | + */ | ||
21 | + let authService: any = helpers.mocks.authService; | ||
22 | + let user = <noosfero.User>{ person: person }; | ||
23 | + let sessionService: any = <any>helpers.mocks.sessionWithCurrentUser(user); | ||
24 | + let state = jasmine.createSpyObj("$state", ["go"]); | ||
25 | + let scope = helpers.mocks.scopeWithEvents; | ||
26 | + | ||
27 | + let providers = [ | ||
28 | + new Provider('SessionService', { useValue: sessionService }), | ||
29 | + new Provider('$state', { useValue: state }), | ||
30 | + new Provider('AuthService', { useValue: authService }), | ||
31 | + new Provider('$scope', { useValue: scope }) | ||
32 | + ]; | ||
33 | + | ||
34 | + beforeEach( angular.mock.module("templates") ); | ||
35 | + | ||
36 | + beforeEach( (done: Function) => { | ||
37 | + let cls = createClass({ | ||
38 | + template: htmlTemplate, | ||
39 | + directives: [LoginBlockComponent], | ||
40 | + providers: providers, | ||
41 | + properties: {} | ||
42 | + }); | ||
43 | + helper = new ComponentTestHelper<LoginBlockComponent>(cls, done); | ||
44 | + }); | ||
45 | + | ||
46 | + it("expect person to be null with no logged in user", () => { | ||
47 | + expect(helper.component.currentUser).toBeNull; | ||
48 | + }); | ||
49 | + | ||
50 | + it("expect person to be defined when user login", () => { | ||
51 | + // Executes the login method on the component | ||
52 | + doComponentLogin(); | ||
53 | + expect(helper.component.currentUser.person).toBe(person); | ||
54 | + }); | ||
55 | + | ||
56 | + it("expect person to be null when user logout", () => { | ||
57 | + // First do a login | ||
58 | + doComponentLogin(); | ||
59 | + // The logout the user | ||
60 | + doComponentLogout(); | ||
61 | + // Check if the current user was cleared | ||
62 | + expect(helper.component.currentUser).toBeNull; | ||
63 | + }); | ||
64 | + | ||
65 | + /** | ||
66 | + * Execute the logout method on the target component | ||
67 | + */ | ||
68 | + function doComponentLogout() { | ||
69 | + // Create a mock for the AuthService logout method | ||
70 | + spyOn(authService, "logout"); | ||
71 | + helper.component.logout(); | ||
72 | + expect(authService.logout).toHaveBeenCalled(); | ||
73 | + // After the component logout method execution, fire the | ||
74 | + // AuthService event | ||
75 | + simulateLogoutEvent(); | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * Execute the login method on the target component | ||
80 | + */ | ||
81 | + function doComponentLogin() { | ||
82 | + // Create a mock for the AuthService login method | ||
83 | + spyOn(authService, "login"); | ||
84 | + helper.component.login(); | ||
85 | + expect(authService.login).toHaveBeenCalled(); | ||
86 | + // After the component login method execution, fire the | ||
87 | + // AuthService event | ||
88 | + simulateLoginEvent(); | ||
89 | + } | ||
90 | + | ||
91 | + /** | ||
92 | + * Simulate the AuthService loginSuccess event | ||
93 | + */ | ||
94 | + function simulateLoginEvent() { | ||
95 | + let successEvent: string = AuthEvents[AuthEvents.loginSuccess]; | ||
96 | + | ||
97 | + (<any>helper.component.authService)[successEvent].next(user); | ||
98 | + } | ||
99 | + | ||
100 | + /** | ||
101 | + * Simulate the AuthService logoutSuccess event | ||
102 | + */ | ||
103 | + function simulateLogoutEvent() { | ||
104 | + let successEvent: string = AuthEvents[AuthEvents.logoutSuccess]; | ||
105 | + | ||
106 | + (<any>helper.component.authService)[successEvent].next(user); | ||
107 | + } | ||
108 | + }); | ||
109 | + | ||
110 | +}); | ||
0 | \ No newline at end of file | 111 | \ No newline at end of file |
@@ -0,0 +1,73 @@ | @@ -0,0 +1,73 @@ | ||
1 | +import {Input, Inject, Component} from "ng-forward"; | ||
2 | +import {SessionService, AuthService, AuthEvents} from "./../../../login"; | ||
3 | + | ||
4 | +/** | ||
5 | + * @ngdoc controller | ||
6 | + * @name layout.blocks.LoginBlockComponent | ||
7 | + * @description | ||
8 | + * The Noosfero block responible for presenting a login form and user status | ||
9 | + */ | ||
10 | +@Component({ | ||
11 | + selector: "noosfero-login-block", | ||
12 | + templateUrl: 'app/layout/blocks/login-block/login-block.html', | ||
13 | +}) | ||
14 | +@Inject("SessionService", "$state", 'AuthService', "$scope") | ||
15 | +export class LoginBlockComponent { | ||
16 | + | ||
17 | + /** | ||
18 | + * @ngdoc property | ||
19 | + * @name currentUser | ||
20 | + * @propertyOf layout.blocks.LoginBlockComponent | ||
21 | + * @description | ||
22 | + * The current loged in user | ||
23 | + */ | ||
24 | + currentUser: noosfero.User; | ||
25 | + | ||
26 | + /** | ||
27 | + * @ngdoc property | ||
28 | + * @name credentials | ||
29 | + * @propertyOf layout.blocks.LoginBlockComponent | ||
30 | + * @description | ||
31 | + * The credentials of the currentUser | ||
32 | + */ | ||
33 | + credentials: noosfero.Credentials; | ||
34 | + | ||
35 | + constructor( | ||
36 | + private session: SessionService, | ||
37 | + private $state: ng.ui.IStateService, | ||
38 | + public authService: AuthService, | ||
39 | + private $scope: ng.IScope) { | ||
40 | + this.currentUser = this.session.currentUser(); | ||
41 | + | ||
42 | + this.authService.subscribe(AuthEvents[AuthEvents.loginSuccess], () => { | ||
43 | + this.currentUser = this.session.currentUser(); | ||
44 | + }); | ||
45 | + | ||
46 | + this.authService.subscribe(AuthEvents[AuthEvents.logoutSuccess], () => { | ||
47 | + this.currentUser = this.session.currentUser(); | ||
48 | + }); | ||
49 | + | ||
50 | + } | ||
51 | + | ||
52 | + /** | ||
53 | + * @ngdoc method | ||
54 | + * @name login | ||
55 | + * @methodOf layout.blocks.LoginBlockComponent | ||
56 | + * @description | ||
57 | + * Logs in the user using its credentials | ||
58 | + */ | ||
59 | + login() { | ||
60 | + this.authService.login(this.credentials); | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * @ngdoc method | ||
65 | + * @name logout | ||
66 | + * @methodOf layout.blocks.LoginBlockComponent | ||
67 | + * @description | ||
68 | + * Logout the user | ||
69 | + */ | ||
70 | + logout() { | ||
71 | + this.authService.logout(); | ||
72 | + }; | ||
73 | +} |
@@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
1 | +<div class="logged-user-info" ng-show="ctrl.currentUser"> | ||
2 | + <h4>Logged in as {{ctrl.currentUser.person.identifier}}</h4> | ||
3 | + <ul> | ||
4 | + <li>User since | ||
5 | + <span class="time"> | ||
6 | + <span am-time-ago="ctrl.currentUser.person.created_at | dateFormat"></span> | ||
7 | + </span> | ||
8 | + </li> | ||
9 | + <li><a ui-sref="main.profile.info({profile: ctrl.currentUser.person.identifier})">Profile Homepage</a></li> | ||
10 | + </ul> | ||
11 | + <div class="user-actions"> | ||
12 | + <a href="#" ng-click="ctrl.logout()"><i class="fa fa-fw fa-power-off"></i> {{"navbar.logout" | translate}}</a> | ||
13 | + </div> | ||
14 | +</div> | ||
15 | +<div class="logged-user-info" ng-show="!ctrl.currentUser"> | ||
16 | + <form> | ||
17 | + <div class="form-group"> | ||
18 | + <label for="exampleInputEmail1">{{"auth.form.login" | translate}}</label> | ||
19 | + <input type="text" class="form-control" id="exampleInputEmail1" placeholder="Login / Email" ng-model="ctrl.credentials.username"> | ||
20 | + </div> | ||
21 | + <div class="form-group"> | ||
22 | + <label for="exampleInputPassword1">{{"auth.form.password" | translate}}</label> | ||
23 | + <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password" ng-model="ctrl.credentials.password"> | ||
24 | + </div> | ||
25 | + <button type="submit" class="btn btn-default" ng-click="ctrl.login()">{{"auth.form.login_button" | translate}}</button> | ||
26 | + </form> | ||
27 | +</div> | ||
0 | \ No newline at end of file | 28 | \ No newline at end of file |
@@ -11,13 +11,11 @@ export class SessionService { | @@ -11,13 +11,11 @@ export class SessionService { | ||
11 | 11 | ||
12 | create(data: UserResponse): noosfero.User { | 12 | create(data: UserResponse): noosfero.User { |
13 | this.$localStorage.currentUser = data.user; | 13 | this.$localStorage.currentUser = data.user; |
14 | - this.$log.debug('User session created.', this.$localStorage.currentUser); | ||
15 | return this.$localStorage.currentUser; | 14 | return this.$localStorage.currentUser; |
16 | }; | 15 | }; |
17 | 16 | ||
18 | destroy() { | 17 | destroy() { |
19 | delete this.$localStorage.currentUser; | 18 | delete this.$localStorage.currentUser; |
20 | - this.$log.debug('User session destroyed.'); | ||
21 | }; | 19 | }; |
22 | 20 | ||
23 | currentUser(): noosfero.User { | 21 | currentUser(): noosfero.User { |
@@ -19,6 +19,7 @@ import {StatisticsBlockComponent} from "../layout/blocks/statistics/statistics-b | @@ -19,6 +19,7 @@ import {StatisticsBlockComponent} from "../layout/blocks/statistics/statistics-b | ||
19 | import {MembersBlockComponent} from "./../layout/blocks/members/members-block.component"; | 19 | import {MembersBlockComponent} from "./../layout/blocks/members/members-block.component"; |
20 | import {CommunitiesBlockComponent} from "./../layout/blocks/communities/communities-block.component"; | 20 | import {CommunitiesBlockComponent} from "./../layout/blocks/communities/communities-block.component"; |
21 | 21 | ||
22 | +import {LoginBlockComponent} from "../layout/blocks/login-block/login-block.component"; | ||
22 | 23 | ||
23 | import {NoosferoTemplate} from "../shared/pipes/noosfero-template.filter"; | 24 | import {NoosferoTemplate} from "../shared/pipes/noosfero-template.filter"; |
24 | import {DateFormat} from "../shared/pipes/date-format.filter"; | 25 | import {DateFormat} from "../shared/pipes/date-format.filter"; |
@@ -96,7 +97,8 @@ export class EnvironmentContent { | @@ -96,7 +97,8 @@ export class EnvironmentContent { | ||
96 | EnvironmentComponent, PeopleBlockComponent, | 97 | EnvironmentComponent, PeopleBlockComponent, |
97 | LinkListBlockComponent, CommunitiesBlockComponent, HtmlEditorComponent, | 98 | LinkListBlockComponent, CommunitiesBlockComponent, HtmlEditorComponent, |
98 | MainBlockComponent, RecentDocumentsBlockComponent, Navbar, SidebarComponent, ProfileImageBlockComponent, | 99 | MainBlockComponent, RecentDocumentsBlockComponent, Navbar, SidebarComponent, ProfileImageBlockComponent, |
99 | - MembersBlockComponent, NoosferoTemplate, DateFormat, RawHTMLBlockComponent, StatisticsBlockComponent | 100 | + MembersBlockComponent, NoosferoTemplate, DateFormat, RawHTMLBlockComponent, StatisticsBlockComponent, |
101 | + LoginBlockComponent | ||
100 | ].concat(plugins.mainComponents).concat(plugins.hotspots), | 102 | ].concat(plugins.mainComponents).concat(plugins.hotspots), |
101 | 103 | ||
102 | providers: [AuthService, SessionService, NotificationService, BodyStateClassesService] | 104 | providers: [AuthService, SessionService, NotificationService, BodyStateClassesService] |
@@ -6,6 +6,5 @@ namespace noosfero { | @@ -6,6 +6,5 @@ namespace noosfero { | ||
6 | * A representation of a Person in Noosfero. | 6 | * A representation of a Person in Noosfero. |
7 | */ | 7 | */ |
8 | export interface Person extends Profile { | 8 | export interface Person extends Profile { |
9 | - | ||
10 | } | 9 | } |
11 | } | 10 | } |
12 | \ No newline at end of file | 11 | \ No newline at end of file |
@@ -22,6 +22,14 @@ namespace noosfero { | @@ -22,6 +22,14 @@ namespace noosfero { | ||
22 | * @returns {string} The unque identifier for the Profile | 22 | * @returns {string} The unque identifier for the Profile |
23 | */ | 23 | */ |
24 | identifier: string; | 24 | identifier: string; |
25 | + | ||
26 | + /** | ||
27 | + * @ngdoc property | ||
28 | + * @name created_at | ||
29 | + * @propertyOf noofero.Profile | ||
30 | + * @returns {string} The timestamp this object was created | ||
31 | + */ | ||
32 | + created_at: string; | ||
25 | 33 | ||
26 | /** | 34 | /** |
27 | * @ngdoc property | 35 | * @ngdoc property |
@@ -2,6 +2,7 @@ import { Component } from "ng-forward"; | @@ -2,6 +2,7 @@ import { Component } from "ng-forward"; | ||
2 | import { TestComponentBuilder, ngClass } from 'ng-forward/cjs/testing/test-component-builder'; | 2 | import { TestComponentBuilder, ngClass } from 'ng-forward/cjs/testing/test-component-builder'; |
3 | import { INgForwardJQuery } from "ng-forward/cjs/util/jqlite-extensions"; | 3 | import { INgForwardJQuery } from "ng-forward/cjs/util/jqlite-extensions"; |
4 | import { ComponentFixture } from 'ng-forward/cjs/testing/test-component-builder'; | 4 | import { ComponentFixture } from 'ng-forward/cjs/testing/test-component-builder'; |
5 | +import * as helpers from './helpers'; | ||
5 | 6 | ||
6 | /** | 7 | /** |
7 | * @ngdoc object | 8 | * @ngdoc object |
@@ -149,6 +150,7 @@ export function createClass({ | @@ -149,6 +150,7 @@ export function createClass({ | ||
149 | providers = <any[]>[], | 150 | providers = <any[]>[], |
150 | properties = <any>{} | 151 | properties = <any>{} |
151 | }): any { | 152 | }): any { |
153 | + providers = providers.concat(helpers.provideFilters("translateFilter")); | ||
152 | @Component({ selector: 'component-test-helper-container', template, directives, providers }) | 154 | @Component({ selector: 'component-test-helper-container', template, directives, providers }) |
153 | class Test { | 155 | class Test { |
154 | constructor() { | 156 | constructor() { |
@@ -68,6 +68,7 @@ export var mocks: any = { | @@ -68,6 +68,7 @@ export var mocks: any = { | ||
68 | mocks.authService['logoutSuccess'].event(param); | 68 | mocks.authService['logoutSuccess'].event(param); |
69 | } | 69 | } |
70 | }, | 70 | }, |
71 | + login: () => { }, | ||
71 | logout: () => { }, | 72 | logout: () => { }, |
72 | subscribe: (eventName: string, fn: Function) => { | 73 | subscribe: (eventName: string, fn: Function) => { |
73 | mocks.authService[eventName].subscribe(fn); | 74 | mocks.authService[eventName].subscribe(fn); |
-
Reassigned to @mfdeveloper
-
Esta alteração não foi deste branch. Também não entendi.
-
O uso de
$scope
para callback de eventos é uma abordagem do Angular 1.x que deve ser evitada. Ao invés disso, utilize a classeEventEmitter
como sugerido pelong-forward
-
Qual a diferença neste mock? Me pareceu que não houve alteração
-
O uso de $emit para executar callbacks de eventos é uma abordagem do Angular 1.x que deve ser evitada. Ao invés disso, utilize o método
EventEmitter.next()
ouEventEmitter.emit()
como sugerido pelong-forward
-
Substituir uso de
$scope
paraEventEmitter
aq tbm! -
A biblioteca
moment
que estamos utilizando como dependência no projeto possui alguns métodos para exibir essas informações de data. Por favor, verifique se não há uma que já faça isso -
identifier
ecreated_at
não são dados específicos dePerson
, mas sim de qualquerProfile
(Comunidades, Organizações...). Não seria melhor mover esses atributos para Profile? -
Added 92 new commits:
- 0fdd5d98 - picture for people block participa-consulta-theme
- 1f4da208 - People block style
- 976e5d62 - Fix state change of sidebar
- 172c82f5 - Add discussion block for comment paragraph
- f9a71d96 - Refactor of article cms
- 7352b22a - Dynamically load article editor component based on specific type
- 6b394e0b - Add component to edit comment paragraph discussions
- d56bc4d4 - Do now show comment form when article doesn't accept comments
- a68fcd7a - Add hotspot to display extra content for articles
- c046c510 - Display period for discussions in comment paragraph plugin
- 34b11fee - Fix warnings in typescript code
- afd487b0 - Merge branch 'comment-paragraph-article' into 'master'
- 8af6d143 - Fix merge with comment-paragraph
- 8362948a - adding participa consulta theme
- e59add5d - Created sidebar component with sass and a service to show/hide using Angular 2 EventEmitter sintax
- 4c39bd75 - Added hamburguer sidebar toggle button to show only after login
- 41cad538 - Refactory into unit tests to use EventEmitter mocks
- f711ee9c - Refactory into ComponentTestHelper and sidebar unit tests enhancements
- dd6a4819 - Added feature to sidebar pushing right content on show/hide
- af427f22 - Created SidebarSectionsComponent with a dinamic menu/submenu
- 7e4cecee - Added @ngdoc documentation and refactor the SidebarSection component
- c0fd7cf6 - Merge branch 'sidebar-menu' into 'master'
- 2cafe5da - Add macro directive for articles
- 4b4877ed - Load components defined in plugins
- 33544a8b - Add plugins in gulp build
- 31b34a75 - Display paragraph comments besides the article
- 1f246d3f - Load comments by paragraph
- 56a44bd2 - Create infra for plugins hotspots
- 5deddf45 - Set parahraph uuid when create comments in paragraphs
- abdfbb35 - Activate/deactivate comment paragraph in articles
- b77b920c - Emit event when toggle comment paragraph in articles
- 8a1cb95c - Display comment counts beside paragraphs
- 65c6a4ac - Merge plugin languages when building with gulp
- 9bf4d461 - Improve layout of comment paragraph plugin
- 7b6978a6 - Fix html path in karma conf
- f98ac330 - Add tests for comment paragraph plugin
- 4840baa9 - Add paragraph uuid in comment form
- 800e2559 - Limit comments identation and display replied comment in tooltip
- 12f1379f - Merge branch 'comment-paragraph' into 'master'
- ed34cf65 - Support ckeditor in article edition
- 28d86107 - Support storage of current object in generic restangular service
- 2259690d - Create article and associate it to parent
- a5984494 - Move basic editor to its own folder
- ecac812c - Add cancel button in basic editor
- ed2107bd - Translate basic editor component
- 33ae65dd - Adapt basic editor to edit an existing article
- 8f0e4db1 - Create component to encapsulate wysiwyg editor
- 6b15acb7 - Add article edit button
- ba389ecc - Edit visibility status of an article
- 00eaab03 - Display basic error message when fail to save an article
- 5f9ef2ae - Refactor tests of content viewer actions to use ComponentTestHelper
- 1894afc0 - Merge branch 'create-article' into 'master'
- 8616dd98 - Add missing type arguments from members and people blocks
- dcc1120f - Fix styles watch from gulp
- 5eeecfe1 - Added header and footer, no tests yet
- 0526d30c - Merge branch 'header_and_footer' into 'master'
- 2f289f34 - Merge branch 'master' of softwarepublico.gov.br:noosfero-themes/angular-theme
- 98521917 - Restore missing code after merge with comment-paragraph
- 12039f0c - Fix warnings in comment-paragraph
- 9cb82c98 - removing warning
- 8c7b12aa - refactoring communities block
- 34d5ef65 - refactoring link list block
- 11081744 - refactoring main block
- 2b6b1400 - refactoring members block
- ea43a611 - refactoring people block
- 56073cfd - refactoring profile image block
- da32e022 - refactoring raw html block
- 9b3a27c9 - refactoring recent documents block
- c73e431e - adding basic information of statisticst block
- 5af8017d - Adding counters to statistics block
- 2efd5865 - adding unit test for statistics block
- 2418a97b - fix merge conflit
- c1b134be - comment style
- 299d40d1 - updated to use statistics array property in statistic block to fill the statistic block content
- a5a76711 - Merge branch 'statistics_block' into 'master'
- e99067c1 - Merge branch 'master' of softwarepublico.gov.br:noosfero-themes/angular-theme
- f0fe6b59 - adding new button to comment paragraph
- 5e8f7a89 - save articles without parent
- 1aa2ffcc - Merge branch 'master' of softwarepublico.gov.br:noosfero-themes/angular-theme
- 2cf099d7 - Fix warning in discussion block
- e6fc72ab - Fix noosfero layout
- dcb9f310 - fix grid configuration degrid
- 5727b1d8 - Fix build of ckeditor
- 4e270e6c - Fix gulp conf
- 246f026b - Do not show discussion header in regular articles
- b4421c0d - Fix warning in body states classes service
- 39a5fc2d - Merge branch 'master' of softwarepublico.gov.br:noosfero-themes/angular-theme
- 58a458df - people block style for participa consulta
- 8dde2ffd - using inheritance of classes for box
- 9cf0c6e6 - statistics block style for participa consulta theme
- ab10b960 - align center header content for participa consulta theme
- 49c1ee26 - Merging with master
-
mentioned in commit 5161636a08ea267906fc341042d3a33afbe22f75
9 | - @Input() comment: noosfero.Comment; | |
10 | + @Input() comment: noosfero.CommentViewModel; | |
10 | 11 | @Input() article: noosfero.Article; |
11 | 12 | |
12 | - showReply: boolean = false; | |
13 | + showReply() { | |
14 | + return this.comment && this.comment.__show_reply === true; | |
15 | + } | |
16 | + | |
17 | + constructor() { | |
18 | + } | |
19 | + | |
13 | 20 | |
14 | 21 | reply() { |
15 | - this.showReply = true; | |
22 | + this.comment.__show_reply = !this.comment.__show_reply; | |
2 |
|
27 | + * @ngdoc property | |
28 | + * @name credentials | |
29 | + * @propertyOf layout.blocks.LoginBlockComponent | |
30 | + * @description | |
31 | + * The credentials of the currentUser | |
32 | + */ | |
33 | + credentials: noosfero.Credentials; | |
34 | + | |
35 | + constructor( | |
36 | + private session: SessionService, | |
37 | + private $state: ng.ui.IStateService, | |
38 | + private authService: AuthService, | |
39 | + private $scope: ng.IScope) { | |
40 | + this.currentUser = this.session.currentUser(); | |
41 | + | |
42 | + this.$scope.$on(AUTH_EVENTS.loginSuccess, () => { | |
1 |
|
41 | 41 | } |
42 | 42 | }, |
43 | 43 | authService: { |
44 | - logout: () => { } | |
44 | + logout: () => { }, | |
1 |
|
89 | + } | |
90 | + | |
91 | + /** | |
92 | + * Simulate the AuthService loginSuccess event | |
93 | + */ | |
94 | + function simulateLogin() { | |
95 | + let localScope: ng.IScope = helper.component["$scope"]; | |
96 | + localScope.$emit(AUTH_EVENTS.loginSuccess); | |
97 | + } | |
98 | + | |
99 | + /** | |
100 | + * Simulate the AuthService logoutSuccess event | |
101 | + */ | |
102 | + function simulateLogout() { | |
103 | + let localScope: ng.IScope = helper.component["$scope"]; | |
104 | + localScope.$emit(AUTH_EVENTS.logoutSuccess); | |
1 |
|
41 | 41 | |
42 | 42 | this.$scope.$on(AUTH_EVENTS.loginSuccess, () => { |
43 | 43 | this.currentUser = this.session.currentUser(); |
44 | + console.debug("User: ", this.currentUser); | |
44 | 45 | }); |
45 | 46 | |
46 | 47 | this.$scope.$on(AUTH_EVENTS.logoutSuccess, () => { |
1 |
|
1 | 1 | <div class="logged-user-info" ng-show="ctrl.currentUser"> |
2 | 2 | <h4>Logged in as {{ctrl.currentUser.person.identifier}}</h4> |
3 | 3 | <ul> |
4 | - <li>User since {{ctrl.currentUser.created_at.month}}/{{ctrl.currentUser.created_at.year}}</li> | |
1 |
|
6 | 6 | * A representation of a Person in Noosfero. |
7 | 7 | */ |
8 | 8 | export interface Person extends Profile { |
9 | - | |
9 | + created_at: string; | |
1 |
|