import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { BaseService } from './base.service';

const AUTH_API = 'http://localhost:8080/api/auth/';


@Injectable({
  providedIn: 'root'
})
export class AuthService {

	constructor(public baseService: BaseService) {}

  login(data:any): Observable<any> {
    return this.baseService.postData(AUTH_API+'authenticate',data);
  }

  /*register(username: string, email: string, password: string): Observable<any> {
    return this.http.post(
      AUTH_API + 'signup',
      {
        username,
        email,
        password,
      },
      httpOptions
    );
  }
*/
  logout(): Observable<any> {
    return this.baseService.postData(AUTH_API + 'logout', { });
  }

  refreshToken(refToken:string|null) {
    return this.baseService.getData('auth/refreshtoken/'+refToken);
  }
}
