Removing need for spam_timer

This commit is contained in:
Dessalines 2019-05-15 09:32:33 -07:00
parent 388b5d492b
commit db63212fe1
5 changed files with 2 additions and 29 deletions

View file

@ -68,8 +68,7 @@ Only the first user will be able to be the admin.
email: Option<String>, email: Option<String>,
password: String, password: String,
password_verify: String, password_verify: String,
admin: bool, admin: bool
spam_timeri: i64,
} }
} }
``` ```

View file

@ -15,7 +15,6 @@ pub struct Register {
password: String, password: String,
password_verify: String, password_verify: String,
admin: bool, admin: bool,
spam_timeri: i64,
} }
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
@ -133,10 +132,6 @@ impl Perform<LoginResponse> for Oper<Register> {
return Err(APIError::err(&self.op, "Passwords do not match."))? return Err(APIError::err(&self.op, "Passwords do not match."))?
} }
if data.spam_timeri < 1142 {
return Err(APIError::err(&self.op, "Too fast"))?
}
if has_slurs(&data.username) { if has_slurs(&data.username) {
return Err(APIError::err(&self.op, "No slurs"))? return Err(APIError::err(&self.op, "No slurs"))?
} }

View file

@ -10,7 +10,6 @@ interface State {
registerForm: RegisterForm; registerForm: RegisterForm;
loginLoading: boolean; loginLoading: boolean;
registerLoading: boolean; registerLoading: boolean;
spamNada: string;
} }
@ -27,11 +26,9 @@ export class Login extends Component<any, State> {
password: undefined, password: undefined,
password_verify: undefined, password_verify: undefined,
admin: false, admin: false,
spam_timeri: undefined,
}, },
loginLoading: false, loginLoading: false,
registerLoading: false, registerLoading: false,
spamNada: undefined
} }
constructor(props: any, context: any) { constructor(props: any, context: any) {
@ -103,7 +100,6 @@ export class Login extends Component<any, State> {
return ( return (
<form onSubmit={linkEvent(this, this.handleRegisterSubmit)}> <form onSubmit={linkEvent(this, this.handleRegisterSubmit)}>
<h5>Sign Up</h5> <h5>Sign Up</h5>
<input type="text" class="no-s-hows" value={this.state.spamNada} onInput={linkEvent(this, this.handleSpamNada)} />
<div class="form-group row"> <div class="form-group row">
<label class="col-sm-2 col-form-label">Username</label> <label class="col-sm-2 col-form-label">Username</label>
<div class="col-sm-10"> <div class="col-sm-10">
@ -128,7 +124,6 @@ export class Login extends Component<any, State> {
<input type="password" value={this.state.registerForm.password_verify} onInput={linkEvent(this, this.handleRegisterPasswordVerifyChange)} class="form-control" required /> <input type="password" value={this.state.registerForm.password_verify} onInput={linkEvent(this, this.handleRegisterPasswordVerifyChange)} class="form-control" required />
</div> </div>
</div> </div>
<input type="hidden" value={this.state.registerForm.spam_timeri} />
<div class="form-group row"> <div class="form-group row">
<div class="col-sm-10"> <div class="col-sm-10">
<button type="submit" class="btn btn-secondary">{this.state.registerLoading ? <button type="submit" class="btn btn-secondary">{this.state.registerLoading ?
@ -162,25 +157,11 @@ export class Login extends Component<any, State> {
i.state.registerLoading = true; i.state.registerLoading = true;
i.setState(i.state); i.setState(i.state);
let endTimer = new Date().getTime();
let elapsed = endTimer - i.state.registerForm.spam_timeri;
i.state.registerForm.spam_timeri = elapsed;
if (elapsed > 1423 && i.state.spamNada == undefined) {
WebSocketService.Instance.register(i.state.registerForm); WebSocketService.Instance.register(i.state.registerForm);
} else {
window.location.href = "https://github.com/dessalines/lemmy";
}
} }
handleRegisterUsernameChange(i: Login, event: any) { handleRegisterUsernameChange(i: Login, event: any) {
i.state.registerForm.username = event.target.value; i.state.registerForm.username = event.target.value;
i.state.registerForm.spam_timeri = new Date().getTime();
i.setState(i.state);
}
handleSpamNada(i: Login, event: any) {
i.state.spamNada = event.target.value;
i.setState(i.state); i.setState(i.state);
} }

View file

@ -20,7 +20,6 @@ export class Setup extends Component<any, State> {
username: undefined, username: undefined,
password: undefined, password: undefined,
password_verify: undefined, password_verify: undefined,
spam_timeri: 3000,
admin: true, admin: true,
}, },
doneRegisteringUser: false, doneRegisteringUser: false,

View file

@ -333,7 +333,6 @@ export interface RegisterForm {
email?: string; email?: string;
password: string; password: string;
password_verify: string; password_verify: string;
spam_timeri: number;
admin: boolean; admin: boolean;
} }