mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 06:36:14 +00:00
Spam
This commit is contained in:
parent
66cbd050a1
commit
4625aa3060
|
@ -92,7 +92,7 @@ pub struct Register {
|
||||||
password: String,
|
password: String,
|
||||||
password_verify: String,
|
password_verify: String,
|
||||||
admin: bool,
|
admin: bool,
|
||||||
spam_timer: i64,
|
spam_timeri: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
|
@ -790,7 +790,7 @@ impl Perform for Register {
|
||||||
return Err(self.error("Passwords do not match."))?
|
return Err(self.error("Passwords do not match."))?
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.spam_timer < 1142 {
|
if self.spam_timeri < 1142 {
|
||||||
return Err(self.error("Too fast"))?
|
return Err(self.error("Too fast"))?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ export class Login extends Component<any, State> {
|
||||||
password: undefined,
|
password: undefined,
|
||||||
password_verify: undefined,
|
password_verify: undefined,
|
||||||
admin: false,
|
admin: false,
|
||||||
spam_timer: undefined,
|
spam_timeri: undefined,
|
||||||
},
|
},
|
||||||
loginLoading: false,
|
loginLoading: false,
|
||||||
registerLoading: false,
|
registerLoading: false,
|
||||||
|
@ -103,6 +103,7 @@ 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">
|
||||||
|
@ -127,9 +128,7 @@ 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_timer} />
|
<input type="hidden" value={this.state.registerForm.spam_timeri} />
|
||||||
<input type="text" class="d-none" value={this.state.spamNada} onInput={linkEvent(this, this.handleSpamNada)} />
|
|
||||||
<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">
|
||||||
<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 ?
|
||||||
|
@ -165,21 +164,19 @@ export class Login extends Component<any, State> {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
let endTimer = new Date().getTime();
|
let endTimer = new Date().getTime();
|
||||||
let elapsed = endTimer - i.state.registerForm.spam_timer;
|
let elapsed = endTimer - i.state.registerForm.spam_timeri;
|
||||||
|
|
||||||
i.state.registerForm.spam_timer = elapsed;
|
i.state.registerForm.spam_timeri = elapsed;
|
||||||
if (elapsed > 1423 && i.state.spamNada == undefined) {
|
if (elapsed > 1423 && i.state.spamNada == undefined) {
|
||||||
WebSocketService.Instance.register(i.state.registerForm);
|
WebSocketService.Instance.register(i.state.registerForm);
|
||||||
} else {
|
} else {
|
||||||
i.state.spamNada = "nt";
|
window.location.href = "https://github.com/dessalines/lemmy";
|
||||||
i.setState(i.state);
|
|
||||||
{/* 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_timer = new Date().getTime();
|
i.state.registerForm.spam_timeri = new Date().getTime();
|
||||||
i.setState(i.state);
|
i.setState(i.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,5 +102,7 @@ blockquote {
|
||||||
}
|
}
|
||||||
|
|
||||||
.no-s-hows {
|
.no-s-hows {
|
||||||
display: none;
|
position: absolute !important;
|
||||||
|
top: -9999px !important;
|
||||||
|
left: -9999px !important;
|
||||||
}
|
}
|
||||||
|
|
|
@ -330,7 +330,7 @@ export interface RegisterForm {
|
||||||
email?: string;
|
email?: string;
|
||||||
password: string;
|
password: string;
|
||||||
password_verify: string;
|
password_verify: string;
|
||||||
spam_timer: number;
|
spam_timeri: number;
|
||||||
admin: boolean;
|
admin: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue