From 4be49e915e42e33883bac9599f33b30455982672 Mon Sep 17 00:00:00 2001 From: Caio SBA Date: Mon, 30 May 2016 19:31:18 -0300 Subject: [PATCH] Fixing registration - it is working now --- src/app/account/index.ts | 1 + src/app/account/register-component.html | 4 ++-- src/app/account/register.component.ts | 23 +++++++++++++++-------- src/app/account/register.service.ts | 13 ------------- src/app/login/session.service.ts | 2 +- src/app/main/main.component.ts | 5 ++--- src/lib/ng-noosfero-api/http/register.service.ts | 14 ++++++++++++++ 7 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 src/app/account/index.ts delete mode 100644 src/app/account/register.service.ts create mode 100644 src/lib/ng-noosfero-api/http/register.service.ts diff --git a/src/app/account/index.ts b/src/app/account/index.ts new file mode 100644 index 0000000..766d67c --- /dev/null +++ b/src/app/account/index.ts @@ -0,0 +1 @@ +export * from "./register.component"; diff --git a/src/app/account/register-component.html b/src/app/account/register-component.html index da6b922..a9b4388 100644 --- a/src/app/account/register-component.html +++ b/src/app/account/register-component.html @@ -37,7 +37,7 @@
- +
@@ -45,7 +45,7 @@
- +
diff --git a/src/app/account/register.component.ts b/src/app/account/register.component.ts index 283b341..2d8324e 100644 --- a/src/app/account/register.component.ts +++ b/src/app/account/register.component.ts @@ -1,18 +1,25 @@ -import { Inject, Input, Component, Output, EventEmitter } from 'ng-forward'; -import { RegisterService } from './register.service'; +import { Inject, Input, Component, Output, EventEmitter, provide } from 'ng-forward'; +import {RegisterService} from "./../../lib/ng-noosfero-api/http/register.service"; @Component({ selector: 'noosfero-register', - templateUrl: 'app/account/register-component.html' + templateUrl: 'app/account/register-component.html', + providers: [ + provide('registerService', { useClass: RegisterService }) + ] }) -@Inject(RegisterService) +@Inject("$state", RegisterService) export class RegisterComponent { - constructor(private registerService: RegisterService) { } + @Input() account: any; - signup (account: any) { - if (account.password === account.passwordConfirmation) { - this.registerService.createAccount(account); + constructor(private $state: ng.ui.IStateService, public registerService: RegisterService) { + this.account = {}; + } + + signup() { + if (this.account.password === this.account.password_confirmation) { + this.registerService.createAccount(this.account); } else { alert("Wrong password confirmation."); } diff --git a/src/app/account/register.service.ts b/src/app/account/register.service.ts deleted file mode 100644 index afb19b7..0000000 --- a/src/app/account/register.service.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Injectable, Inject } from "ng-forward"; -import {RestangularService} from "../../lib/ng-noosfero-api/http/restangular_service"; - -@Injectable() -@Inject("Restangular") -export class RegisterService { - - constructor(private Restangular: restangular.IService) { } - - createAccount(user: noosfero.User): ng.IPromise> { - return this.Restangular.customPOST({account: user}, "register", null); - } -} diff --git a/src/app/login/session.service.ts b/src/app/login/session.service.ts index 07b3f70..4d3ff67 100644 --- a/src/app/login/session.service.ts +++ b/src/app/login/session.service.ts @@ -22,4 +22,4 @@ export class SessionService { return this.$localStorage.currentUser; }; -} \ No newline at end of file +} diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index 470b427..03715e8 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -8,8 +8,6 @@ import {ProfileComponent} from "../profile/profile.component"; import {BoxesComponent} from "../layout/boxes/boxes.component"; import {BlockComponent} from "../layout/blocks/block.component"; import {EnvironmentComponent} from "../environment/environment.component"; -import {RegisterComponent} from "../account/register.component"; -import {RegisterService} from "../account/register.service"; import {EnvironmentHomeComponent} from "../environment/environment-home.component"; import {PeopleBlockComponent} from "../layout/blocks/people/people-block.component"; import {DisplayContentBlockComponent} from "../layout/blocks/display-content/display-content-block.component"; @@ -19,6 +17,7 @@ import {ProfileImageBlockComponent} from "../layout/blocks/profile-image/profile import {RawHTMLBlockComponent} from "../layout/blocks/raw-html/raw-html-block.component"; import {StatisticsBlockComponent} from "../layout/blocks/statistics/statistics-block.component"; import {TagsBlockComponent} from "../layout/blocks/tags/tags-block.component"; +import {RegisterComponent} from "../account/register.component"; import {MembersBlockComponent} from "../layout/blocks/members/members-block.component"; import {CommunitiesBlockComponent} from "../layout/blocks/communities/communities-block.component"; @@ -105,7 +104,7 @@ export class EnvironmentContent { LoginBlockComponent, TagsBlockComponent, RegisterComponent ].concat(plugins.mainComponents).concat(plugins.hotspots), - providers: [AuthService, SessionService, NotificationService, BodyStateClassesService, RegisterService] + providers: [AuthService, SessionService, NotificationService, BodyStateClassesService] }) @StateConfig([ { diff --git a/src/lib/ng-noosfero-api/http/register.service.ts b/src/lib/ng-noosfero-api/http/register.service.ts new file mode 100644 index 0000000..9e1b0cf --- /dev/null +++ b/src/lib/ng-noosfero-api/http/register.service.ts @@ -0,0 +1,14 @@ +import { Injectable, Inject } from "ng-forward"; +import {RestangularService} from "./restangular_service"; + +@Injectable() +@Inject("Restangular") +export class RegisterService { + constructor(private Restangular: restangular.IService) { + this.Restangular = Restangular; + } + + createAccount(user: noosfero.User): ng.IPromise> { + return this.Restangular.all('').customPOST(user, "register", user); + } +} -- libgit2 0.21.2