Prevent registration with duplicate emails.

This commit is contained in:
Dominik Picheta 2018-05-16 14:49:59 +01:00
commit c6b42c5979
3 changed files with 23 additions and 9 deletions

View file

@ -1099,6 +1099,14 @@ proc executeRegister(c: TForumData, name, pass, antibot, userIp,
## Registers a new user and returns a new session key for that user's
## session if registration was successful. Exceptions are raised otherwise.
# email validation
if not ('@' in email and '.' in email):
raise newForumError("Invalid email", @["email"])
if getValue(
db, sql"select email from person where email = ?", email
).len > 0:
raise newForumError("Email already exists", @["email"])
# Username validation:
if name.len == 0 or not allCharsInSet(name, UsernameIdent):
raise newForumError("Invalid username", @["username"])
@ -1118,10 +1126,6 @@ proc executeRegister(c: TForumData, name, pass, antibot, userIp,
"Invalid recaptcha answer", @[]
)
# email validation
if not ('@' in email and '.' in email):
raise newForumError("Invalid email", @["email"])
# perform registration:
var salt = makeSalt()
let password = makePassword(pass, salt)
@ -1142,7 +1146,7 @@ proc executeRegister(c: TForumData, name, pass, antibot, userIp,
exec(db,
sql("INSERT INTO person(name, password, email, salt, status, lastOnline) " &
"VALUES (?, ?, ?, ?, ?, DATETIME('now'))"), name,
password, email, salt, $Moderated)
password, email, salt, $EmailUnconfirmed)
return password

View file

@ -144,6 +144,11 @@ $logo-height: $navbar-height - 20px;
a.visited {
color: lighten($body-font-color, 40%);
}
i {
// Icon
margin-right: $control-padding-x-sm;
}
}
$super-popular-color: #f86713;

View file

@ -100,12 +100,17 @@ when defined(js):
tr(class=class({"no-border": noBorder})):
td(class="thread-title"):
if thread.isLocked:
italic(class="fas fa-lock fa-xs")
italic(class="fas fa-lock fa-xs",
title="Thread cannot be replied to")
if thread.isInvisible:
italic(class="fas fa-eye-slash fa-xs")
italic(class="fas fa-eye-slash fa-xs",
title="Thread is moderated")
if thread.isSolved:
italic(class="fas fa-check-square fa-xs")
a(href=makeUri("/t/" & $thread.id), onClick=anchorCB): text thread.topic
italic(class="fas fa-check-square fa-xs",
title="Thread has a solution")
a(href=makeUri("/t/" & $thread.id),
onClick=anchorCB):
text thread.topic
td():
render(thread.category)
genUserAvatars(thread.users)