|
|
@ -12,28 +12,29 @@ interface State {
|
|
|
|
registerLoading: boolean;
|
|
|
|
registerLoading: boolean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let emptyState: State = {
|
|
|
|
|
|
|
|
loginForm: {
|
|
|
|
|
|
|
|
username_or_email: undefined,
|
|
|
|
|
|
|
|
password: undefined
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
registerForm: {
|
|
|
|
|
|
|
|
username: undefined,
|
|
|
|
|
|
|
|
password: undefined,
|
|
|
|
|
|
|
|
password_verify: undefined,
|
|
|
|
|
|
|
|
admin: false,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
loginLoading: false,
|
|
|
|
|
|
|
|
registerLoading: false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export class Login extends Component<any, State> {
|
|
|
|
export class Login extends Component<any, State> {
|
|
|
|
private subscription: Subscription;
|
|
|
|
private subscription: Subscription;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emptyState: State = {
|
|
|
|
|
|
|
|
loginForm: {
|
|
|
|
|
|
|
|
username_or_email: undefined,
|
|
|
|
|
|
|
|
password: undefined
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
registerForm: {
|
|
|
|
|
|
|
|
username: undefined,
|
|
|
|
|
|
|
|
password: undefined,
|
|
|
|
|
|
|
|
password_verify: undefined,
|
|
|
|
|
|
|
|
admin: false,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
loginLoading: false,
|
|
|
|
|
|
|
|
registerLoading: false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
constructor(props: any, context: any) {
|
|
|
|
constructor(props: any, context: any) {
|
|
|
|
super(props, context);
|
|
|
|
super(props, context);
|
|
|
|
|
|
|
|
|
|
|
|
this.state = emptyState;
|
|
|
|
this.state = this.emptyState;
|
|
|
|
|
|
|
|
|
|
|
|
this.subscription = WebSocketService.Instance.subject
|
|
|
|
this.subscription = WebSocketService.Instance.subject
|
|
|
|
.pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
|
|
|
|
.pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
|
|
|
@ -183,8 +184,7 @@ export class Login extends Component<any, State> {
|
|
|
|
let op: UserOperation = msgOp(msg);
|
|
|
|
let op: UserOperation = msgOp(msg);
|
|
|
|
if (msg.error) {
|
|
|
|
if (msg.error) {
|
|
|
|
alert(msg.error);
|
|
|
|
alert(msg.error);
|
|
|
|
this.state.loginLoading = false;
|
|
|
|
this.state = this.emptyState;
|
|
|
|
this.state.registerLoading = false;
|
|
|
|
|
|
|
|
this.setState(this.state);
|
|
|
|
this.setState(this.state);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|