only provide instance for adding an account

This commit is contained in:
Nicolas Constant 2020-02-14 21:16:03 -05:00
parent be17f56140
commit 6c7915e4b1
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
3 changed files with 15 additions and 22 deletions

View File

@ -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>

View File

@ -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);

View File

@ -59,5 +59,5 @@ export class AuthService {
}
export class CurrentAuthProcess {
constructor(public username: string, public instance: string) { }
constructor(public instance: string) { }
}