Merge pull request #177 from NicolasConstant/develop

0.17.1 PR
This commit is contained in:
Nicolas Constant 2019-10-01 01:45:30 -04:00 committed by GitHub
commit 9a9406cabb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "sengi", "name": "sengi",
"version": "0.17.0", "version": "0.17.1",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"main": "main-electron.js", "main": "main-electron.js",
"description": "A multi-account desktop client for Mastodon and Pleroma", "description": "A multi-account desktop client for Mastodon and Pleroma",

View File

@ -1,5 +1,5 @@
import { Injectable } from "@angular/core"; import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http"; import { HttpClient, HttpHeaders } from "@angular/common/http";
import { ApiRoutes } from './models/api.settings'; import { ApiRoutes } from './models/api.settings';
import { AppData, TokenData } from "./models/mastodon.interfaces"; import { AppData, TokenData } from "./models/mastodon.interfaces";
@ -17,15 +17,24 @@ export class AuthService {
} }
getToken(instance: string, client_id: string, client_secret: string, code: string, redirect_uri: string): Promise<TokenData> { getToken(instance: string, client_id: string, client_secret: string, code: string, redirect_uri: string): Promise<TokenData> {
const url = `https://${instance}/oauth/token?client_id=${client_id}&client_secret=${client_secret}&grant_type=authorization_code&code=${code}&redirect_uri=${encodeURIComponent(redirect_uri)}`; const encodedRedirectUri = encodeURIComponent(redirect_uri);
const url = `https://${instance}/oauth/token?client_id=${client_id}&client_secret=${client_secret}&grant_type=authorization_code&code=${code}&redirect_uri=${encodedRedirectUri}`;
return this.httpClient.post<TokenData>(url, null).toPromise(); const bodyLoad = {
'client_id': client_id,
'client_secret': client_secret,
'grant_type': 'authorization_code',
'redirect_uri': redirect_uri,
'code': code
};
return this.httpClient.post<TokenData>(url, bodyLoad).toPromise();
} }
createNewApplication(instance: string, appName: string, redirectUrl: string, scopes: string, website: string): Promise<AppData> { createNewApplication(instance: string, appName: string, redirectUrl: string, scopes: string, website: string): Promise<AppData> {
const url = 'https://' + instance + this.apiRoutes.createApp; const url = 'https://' + instance + this.apiRoutes.createApp;
const formData = new FormData();
const formData = new FormData();
formData.append('client_name', appName); formData.append('client_name', appName);
formData.append('redirect_uris', redirectUrl); formData.append('redirect_uris', redirectUrl);
formData.append('scopes', scopes); formData.append('scopes', scopes);

View File

@ -31,6 +31,8 @@ export class ToolsService {
type = InstanceType.GlitchSoc; type = InstanceType.GlitchSoc;
} else if (instance.version.toLowerCase().includes('+florence')) { } else if (instance.version.toLowerCase().includes('+florence')) {
type = InstanceType.Florence; type = InstanceType.Florence;
} else if (instance.version.toLowerCase().includes('pixelfed')) {
type = InstanceType.Pixelfed;
} }
var splittedVersion = instance.version.split('.'); var splittedVersion = instance.version.split('.');
@ -39,6 +41,7 @@ export class ToolsService {
var instanceInfo = new InstanceInfo(type, major, minor); var instanceInfo = new InstanceInfo(type, major, minor);
this.instanceInfos[acc.instance] = instanceInfo; this.instanceInfos[acc.instance] = instanceInfo;
return instanceInfo; return instanceInfo;
}); });
} }
@ -171,5 +174,6 @@ export enum InstanceType {
Mastodon = 1, Mastodon = 1,
Pleroma = 2, Pleroma = 2,
GlitchSoc = 3, GlitchSoc = 3,
Florence = 4 Florence = 4,
Pixelfed = 5
} }