Begin support for external auths
[oweals/peertube.git] / client / src / app / core / auth / auth.service.ts
index 9ae008e390ddf00b7dd9182e4b7bcf69b3b9e705..61d755ba0a14eb7651dd6671297cc00c4d143fc2 100644 (file)
@@ -145,7 +145,7 @@ export class AuthService {
     return !!this.getAccessToken()
   }
 
-  login (username: string, password: string) {
+  login (username: string, password: string, token?: string) {
     // Form url encoded
     const body = {
       client_id: this.clientId,
@@ -157,6 +157,8 @@ export class AuthService {
       password
     }
 
+    if (token) Object.assign(body, { externalAuthToken: token })
+
     const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
     return this.http.post<UserLogin>(AuthService.BASE_TOKEN_URL, objectToUrlEncoded(body), { headers })
                .pipe(