Commit ebe4676d5a96e92deac08371b92e8f8064be74f1

Authored by Caio Almeida
Committed by Michel Felipe
1 parent b7edb563

Fixing registration - it is working now

src/app/account/index.ts 0 → 100644
... ... @@ -0,0 +1 @@
  1 +export * from "./register.component";
... ...
src/app/account/register-component.html
... ... @@ -37,7 +37,7 @@
37 37  
38 38 <div class="col-md-6 register-field">
39 39 <label for="password-confirmation">{{"account.register.passwordConfirmationLabel" | translate}}</label>
40   - <input type="password" class="form-control" id="passwordConfirmation" placeholder="Password Confirmation" ng-model="ctrl.account.passwordConfirmation">
  40 + <input type="password" class="form-control" id="passwordConfirmation" placeholder="Password Confirmation" ng-model="ctrl.account.password_confirmation">
41 41 </div>
42 42  
43 43 <div class="col-md-12">
... ... @@ -45,7 +45,7 @@
45 45 </div>
46 46  
47 47 <div class="col-md-12">
48   - <button type="submit" class="btn btn-default" ng-click="ctrl.signup(ctrl.account)">{{"account.register.signupMessage" | translate}}</button>
  48 + <button type="submit" class="btn btn-default" ng-click="ctrl.signup()">{{"account.register.signupMessage" | translate}}</button>
49 49 </div>
50 50  
51 51 </div>
... ...
src/app/account/register.component.ts
1   -import { Inject, Input, Component, Output, EventEmitter } from 'ng-forward';
2   -import { RegisterService } from './register.service';
  1 +import { Inject, Input, Component, Output, EventEmitter, provide } from 'ng-forward';
  2 +import {RegisterService} from "./../../lib/ng-noosfero-api/http/register.service";
3 3  
4 4 @Component({
5 5 selector: 'noosfero-register',
6   - templateUrl: 'app/account/register-component.html'
  6 + templateUrl: 'app/account/register-component.html',
  7 + providers: [
  8 + provide('registerService', { useClass: RegisterService })
  9 + ]
7 10 })
8 11  
9   -@Inject(RegisterService)
  12 +@Inject("$state", RegisterService)
10 13 export class RegisterComponent {
11   - constructor(private registerService: RegisterService) { }
  14 + @Input() account: any;
12 15  
13   - signup (account: any) {
14   - if (account.password === account.passwordConfirmation) {
15   - this.registerService.createAccount(account);
  16 + constructor(private $state: ng.ui.IStateService, public registerService: RegisterService) {
  17 + this.account = {};
  18 + }
  19 +
  20 + signup() {
  21 + if (this.account.password === this.account.password_confirmation) {
  22 + this.registerService.createAccount(this.account);
16 23 } else {
17 24 alert("Wrong password confirmation.");
18 25 }
... ...
src/app/account/register.service.ts
... ... @@ -1,13 +0,0 @@
1   -import { Injectable, Inject } from "ng-forward";
2   -import {RestangularService} from "../../lib/ng-noosfero-api/http/restangular_service";
3   -
4   -@Injectable()
5   -@Inject("Restangular")
6   -export class RegisterService {
7   -
8   - constructor(private Restangular: restangular.IService) { }
9   -
10   - createAccount(user: noosfero.User): ng.IPromise<noosfero.RestResult<noosfero.User>> {
11   - return this.Restangular.customPOST({account: user}, "register", null);
12   - }
13   -}
src/app/login/session.service.ts
... ... @@ -23,4 +23,4 @@ export class SessionService {
23 23 return this.$localStorage.currentUser;
24 24 };
25 25  
26   -}
27 26 \ No newline at end of file
  27 +}
... ...
src/app/main/main.component.ts
... ... @@ -9,7 +9,6 @@ import {BoxesComponent} from &quot;../layout/boxes/boxes.component&quot;;
9 9 import {BlockContentComponent} from "../layout/blocks/block-content.component";
10 10 import {BlockComponent} from "../layout/blocks/block.component";
11 11 import {EnvironmentComponent} from "../environment/environment.component";
12   -import {RegisterComponent} from "../account/register.component";
13 12 import {EnvironmentHomeComponent} from "../environment/environment-home.component";
14 13 import {PeopleBlockComponent} from "../layout/blocks/people/people-block.component";
15 14 import {DisplayContentBlockComponent} from "../layout/blocks/display-content/display-content-block.component";
... ... @@ -22,6 +21,7 @@ import {PersonTagsPluginInterestsBlockComponent} from &quot;../layout/blocks/person-t
22 21 import {TagsBlockComponent} from "../layout/blocks/tags/tags-block.component";
23 22 import {CustomContentComponent} from "../profile/custom-content/custom-content.component";
24 23 import {RecentActivitiesPluginActivitiesBlockComponent} from "../layout/blocks/recent-activities-plugin-activities/recent-activities-plugin-activities-block.component";
  24 +import {RegisterComponent} from "../account/register.component";
25 25  
26 26 import {MembersBlockComponent} from "../layout/blocks/members/members-block.component";
27 27 import {CommunitiesBlockComponent} from "../layout/blocks/communities/communities-block.component";
... ... @@ -35,6 +35,7 @@ import {AuthService} from &quot;../login/auth.service&quot;;
35 35 import {SessionService} from "../login/session.service";
36 36 import {EnvironmentService} from "./../../lib/ng-noosfero-api/http/environment.service";
37 37 import {NotificationService} from "../shared/services/notification.service";
  38 +import {RegisterService} from "./../../lib/ng-noosfero-api/http/register.service";
38 39  
39 40 import {BodyStateClassesService} from "./../layout/services/body-state-classes.service";
40 41  
... ...
src/lib/ng-noosfero-api/http/register.service.ts 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +import { Injectable, Inject } from "ng-forward";
  2 +import {RestangularService} from "./restangular_service";
  3 +
  4 +@Injectable()
  5 +@Inject("Restangular")
  6 +export class RegisterService {
  7 + constructor(private Restangular: restangular.IService) {
  8 + this.Restangular = Restangular;
  9 + }
  10 +
  11 + createAccount(user: noosfero.User): ng.IPromise<noosfero.RestResult<noosfero.User>> {
  12 + return this.Restangular.all('').customPOST(user, "register", user);
  13 + }
  14 +}
... ...