password: String,
password_verify: String,
admin: bool,
+ spam_timer: i64,
}
#[derive(Serialize, Deserialize)]
return Err(self.error("Passwords do not match."))?
}
+ if self.spam_timer < 1142 {
+ return Err(self.error("Too fast"))?
+ }
+
if has_slurs(&self.username) {
return Err(self.error("No slurs"))?
}
registerForm: RegisterForm;
loginLoading: boolean;
registerLoading: boolean;
- spamTimer: number;
}
password: undefined,
password_verify: undefined,
admin: false,
+ spam_timer: undefined,
},
loginLoading: false,
registerLoading: false,
- spamTimer: new Date().getTime()
}
constructor(props: any, context: any) {
<input type="password" value={this.state.registerForm.password_verify} onInput={linkEvent(this, this.handleRegisterPasswordVerifyChange)} class="form-control" required />
</div>
</div>
- <input type="hidden" value={this.state.spamTimer} />
+ <input type="hidden" value={this.state.registerForm.spam_timer} />
<div class="form-group row">
<div class="col-sm-10">
<button type="submit" class="btn btn-secondary">{this.state.registerLoading ?
event.preventDefault();
let endTimer = new Date().getTime();
- let elapsed = endTimer - i.state.spamTimer;
- if (elapsed > 4500) {
+ let elapsed = endTimer - i.state.registerForm.spam_timer;
+
+ i.state.registerForm.spam_timer = elapsed;
+ if (elapsed > 1142) {
WebSocketService.Instance.register(i.state.registerForm);
} else {
- location.reload(true);
+ window.location.href = "https://github.com/dessalines/lemmy";
}
}
handleRegisterUsernameChange(i: Login, event: any) {
i.state.registerForm.username = event.target.value;
+ i.state.registerForm.spam_timer = new Date().getTime();
i.setState(i.state);
}