X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fcore%2Fauth%2Fauth.service.ts;h=61d755ba0a14eb7651dd6671297cc00c4d143fc2;hb=4a8d113b9b57d97ff13ad1608798eabca99643e4;hp=eaa822e0f99aea41852099b1175807e96928be07;hpb=73471b1a52f242e86364ffb077ea6cadb3b07ae2;p=oweals%2Fpeertube.git diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index eaa822e0f..61d755ba0 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts @@ -4,7 +4,7 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { Router } from '@angular/router' import { Notifier } from '@app/core/notification/notifier.service' -import { OAuthClientLocal, User as UserServerModel, UserRefreshToken } from '../../../../../shared' +import { OAuthClientLocal, MyUser as UserServerModel, UserRefreshToken } from '../../../../../shared' import { User } from '../../../../../shared/models/users' import { UserLogin } from '../../../../../shared/models/users/user-login.model' import { environment } from '../../../environments/environment' @@ -12,7 +12,7 @@ import { RestExtractor } from '../../shared/rest/rest-extractor.service' import { AuthStatus } from './auth-status.model' import { AuthUser } from './auth-user.model' import { objectToUrlEncoded } from '@app/shared/misc/utils' -import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' +import { peertubeLocalStorage } from '@app/shared/misc/peertube-web-storage' import { I18n } from '@ngx-translate/i18n-polyfill' import { Hotkey, HotkeysService } from 'angular2-hotkeys' @@ -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(AuthService.BASE_TOKEN_URL, objectToUrlEncoded(body), { headers }) .pipe(