only provide instance for adding an account
This commit is contained in:
parent
be17f56140
commit
6c7915e4b1
|
@ -5,15 +5,15 @@
|
|||
<h2 class="comrade__title" *ngIf="isComrade">Welcome Comrade!</h2>
|
||||
<form (ngSubmit)="onSubmit()">
|
||||
<label [class.comrade__text]="isComrade">Please provide your <span *ngIf="isComrade">comrade</span>
|
||||
account:</label>
|
||||
instance:</label>
|
||||
|
||||
<div>
|
||||
<input type="text" class="form-control form-control-sm form-with-button"
|
||||
[(ngModel)]="mastodonFullHandle" name="mastodonFullHandle" [class.comrade__input]="isComrade"
|
||||
placeholder="@nickname@mastodon.social" />
|
||||
<!-- <br /> -->
|
||||
[(ngModel)]="setInstance" name="instance" [class.comrade__input]="isComrade"
|
||||
placeholder="mastodon.social" />
|
||||
|
||||
<button type="submit" class="form-button"
|
||||
title="add this account"
|
||||
title="add account"
|
||||
[class.comrade__button]="isComrade">
|
||||
<span *ngIf="!isLoading">Submit</span>
|
||||
<app-waiting-animation *ngIf="isLoading" class="waiting-icon"></app-waiting-animation>
|
||||
|
|
|
@ -16,20 +16,17 @@ export class AddNewAccountComponent implements OnInit {
|
|||
private blockList = ['gab.com', 'gab.ai', 'cyzed.com'];
|
||||
private comradeList = ['juche.town'];
|
||||
|
||||
private username: string;
|
||||
private instance: string;
|
||||
isComrade: boolean;
|
||||
|
||||
isLoading: boolean;
|
||||
|
||||
private _mastodonFullHandle: string;
|
||||
private instance: string;
|
||||
@Input()
|
||||
set mastodonFullHandle(value: string) {
|
||||
this._mastodonFullHandle = value;
|
||||
set setInstance(value: string) {
|
||||
this.instance = value;
|
||||
this.checkComrad();
|
||||
}
|
||||
get mastodonFullHandle(): string {
|
||||
return this._mastodonFullHandle;
|
||||
get setInstance(): string {
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
constructor(
|
||||
|
@ -41,11 +38,7 @@ export class AddNewAccountComponent implements OnInit {
|
|||
}
|
||||
|
||||
checkComrad(): any {
|
||||
let fullHandle = this.mastodonFullHandle.split('@').filter(x => x != null && x !== '');
|
||||
this.username = fullHandle[0];
|
||||
this.instance = fullHandle[1];
|
||||
|
||||
if (this.username && this.instance) {
|
||||
if (this.instance) {
|
||||
let cleanInstance = this.instance.replace('http://', '').replace('https://', '').toLowerCase();
|
||||
for (let b of this.comradeList) {
|
||||
if (cleanInstance == b || cleanInstance.includes(`.${b}`)) {
|
||||
|
@ -67,7 +60,7 @@ export class AddNewAccountComponent implements OnInit {
|
|||
|
||||
this.checkAndCreateApplication(this.instance)
|
||||
.then((appData: AppData) => {
|
||||
this.redirectToInstanceAuthPage(this.username, this.instance, appData);
|
||||
this.redirectToInstanceAuthPage(this.instance, appData);
|
||||
})
|
||||
.then(x => {
|
||||
setTimeout(() => {
|
||||
|
@ -140,8 +133,8 @@ export class AddNewAccountComponent implements OnInit {
|
|||
return snapshot.apps;
|
||||
}
|
||||
|
||||
private redirectToInstanceAuthPage(username: string, instance: string, app: AppData) {
|
||||
const appDataTemp = new CurrentAuthProcess(username, instance);
|
||||
private redirectToInstanceAuthPage(instance: string, app: AppData) {
|
||||
const appDataTemp = new CurrentAuthProcess(instance);
|
||||
localStorage.setItem('tempAuth', JSON.stringify(appDataTemp));
|
||||
|
||||
let instanceUrl = this.authService.getInstanceLoginUrl(instance, app.client_id, app.redirect_uri);
|
||||
|
|
|
@ -59,5 +59,5 @@ export class AuthService {
|
|||
}
|
||||
|
||||
export class CurrentAuthProcess {
|
||||
constructor(public username: string, public instance: string) { }
|
||||
constructor(public instance: string) { }
|
||||
}
|
Loading…
Reference in New Issue