diff --git a/src/app/account/register.component.ts b/src/app/account/register.component.ts index 2d8324e..a2f1f16 100644 --- a/src/app/account/register.component.ts +++ b/src/app/account/register.component.ts @@ -14,12 +14,18 @@ export class RegisterComponent { @Input() account: any; constructor(private $state: ng.ui.IStateService, public registerService: RegisterService) { - this.account = {}; + this.account = {}; } signup() { if (this.account.password === this.account.password_confirmation) { - this.registerService.createAccount(this.account); + this.registerService.createAccount(this.account).then((response) => { + if (response.status === 201) { + this.$state.transitionTo('main.environment'); + } else { + throw new Error('Invalid attributes'); + } + }); } else { alert("Wrong password confirmation."); } diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index b58b593..773e460 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -145,7 +145,6 @@ export class EnvironmentContent { url: '/', component: EnvironmentComponent, name: 'main.environment', - abstract: true, views: { "content": { templateUrl: "app/environment/environment.html", diff --git a/src/lib/ng-noosfero-api/http/article.service.spec.ts b/src/lib/ng-noosfero-api/http/article.service.spec.ts index f062eb8..9ebd338 100644 --- a/src/lib/ng-noosfero-api/http/article.service.spec.ts +++ b/src/lib/ng-noosfero-api/http/article.service.spec.ts @@ -17,7 +17,6 @@ describe("Services", () => { articleService = _ArticleService_; })); - describe("Succesfull requests", () => { it("should remove article", (done) => { @@ -92,6 +91,5 @@ describe("Services", () => { }); }); - }); }); diff --git a/src/lib/ng-noosfero-api/http/register.service.ts b/src/lib/ng-noosfero-api/http/register.service.ts index 9e1b0cf..c25dad5 100644 --- a/src/lib/ng-noosfero-api/http/register.service.ts +++ b/src/lib/ng-noosfero-api/http/register.service.ts @@ -9,6 +9,6 @@ export class RegisterService { } createAccount(user: noosfero.User): ng.IPromise> { - return this.Restangular.all('').customPOST(user, "register", user); + return this.Restangular.all("").customPOST(user, "register", user); } } diff --git a/src/lib/ng-noosfero-api/http/restangular_service.ts b/src/lib/ng-noosfero-api/http/restangular_service.ts index e15a60a..e053b7c 100644 --- a/src/lib/ng-noosfero-api/http/restangular_service.ts +++ b/src/lib/ng-noosfero-api/http/restangular_service.ts @@ -80,14 +80,16 @@ export abstract class RestangularService { } return { data: (response.data[dataKey] || response.data), - headers: response.headers + headers: response.headers, + status: response.status }; }; protected buildResult(response: restangular.IResponse): noosfero.RestResult { return { data: response.data, - headers: response.headers + headers: response.headers, + status: response.status }; }; /** diff --git a/src/lib/ng-noosfero-api/interfaces/rest_result.ts b/src/lib/ng-noosfero-api/interfaces/rest_result.ts index 3afca33..afa478a 100644 --- a/src/lib/ng-noosfero-api/interfaces/rest_result.ts +++ b/src/lib/ng-noosfero-api/interfaces/rest_result.ts @@ -3,5 +3,6 @@ namespace noosfero { export interface RestResult { data: T; headers: Function; + status: Number; } -} \ No newline at end of file +} -- libgit2 0.21.2