signup()

in ngo-ui/src/app/ui/signup/signup.component.ts [54:88]


  signup() {
    if (this.loading) {
      return;
    }
    this.loading = true;
    this.submitted = true;
    if (this.userForm.invalid) {
      this.loading = false;
      return;
    }
    const user = this.userForm.value;
    this.userService.createUser(user).subscribe(
      data => {
        if (data.success) {
          this.userService.signup(user).subscribe(
            resp => {
              this.router.navigate(['signin']);
              return;
            },
            err => {
              this.loading = false;
              this.error = err.statusText;
            }
          );
        } else {
          this.loading = false;
          this.error = 'Username or email already in use!';
        }
      },
      err => {
        this.loading = false;
        this.error = err.statusText + ". Ensure you are using HTTP, not HTTPS, to access the site.";
      }
    );
  }