[8423429] | 1 | import { Injectable } from '@angular/core';
|
---|
| 2 | import {ActiveUserInterface} from "./ActiveUserInterface";
|
---|
| 3 | import {HttpClient, HttpParams} from "@angular/common/http";
|
---|
| 4 | import {Router} from "@angular/router";
|
---|
| 5 | import {LoginService} from "./login.service";
|
---|
| 6 |
|
---|
| 7 | @Injectable({
|
---|
| 8 | providedIn: 'root'
|
---|
| 9 | })
|
---|
| 10 | export class RegisterService {
|
---|
| 11 |
|
---|
| 12 | url = "http://localhost:8080/api/register"
|
---|
| 13 | activeUser: ActiveUserInterface | undefined;
|
---|
| 14 | constructor(private http:HttpClient,
|
---|
| 15 | private router: Router,
|
---|
| 16 | private loginService: LoginService) {
|
---|
| 17 | }
|
---|
| 18 | registerUser(name:string, lastName:string, email:string, username:string, password:string, userType:string, index:string){
|
---|
| 19 | const params = new HttpParams()
|
---|
| 20 | .append("name",name)
|
---|
| 21 | .append("lastName",lastName)
|
---|
| 22 | .append("email",email)
|
---|
| 23 | .append("username",username)
|
---|
| 24 | .append("password",password)
|
---|
| 25 | .append("userType",userType)
|
---|
| 26 | .append("index",index);
|
---|
| 27 | this.http.get<ActiveUserInterface>(this.url,{params:params})
|
---|
| 28 | .subscribe(resp =>{
|
---|
| 29 | this.activeUser = resp;
|
---|
| 30 | this.loginService.activeUser = this.activeUser;
|
---|
| 31 | this.router.navigate(['/allCourses']);
|
---|
| 32 | })
|
---|
| 33 | }
|
---|
| 34 | }
|
---|