Prevent registration with duplicate emails.
This commit is contained in:
parent
c338d5e930
commit
c6b42c5979
3 changed files with 23 additions and 9 deletions
14
forum.nim
14
forum.nim
|
|
@ -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
|
## Registers a new user and returns a new session key for that user's
|
||||||
## session if registration was successful. Exceptions are raised otherwise.
|
## 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:
|
# Username validation:
|
||||||
if name.len == 0 or not allCharsInSet(name, UsernameIdent):
|
if name.len == 0 or not allCharsInSet(name, UsernameIdent):
|
||||||
raise newForumError("Invalid username", @["username"])
|
raise newForumError("Invalid username", @["username"])
|
||||||
|
|
@ -1118,10 +1126,6 @@ proc executeRegister(c: TForumData, name, pass, antibot, userIp,
|
||||||
"Invalid recaptcha answer", @[]
|
"Invalid recaptcha answer", @[]
|
||||||
)
|
)
|
||||||
|
|
||||||
# email validation
|
|
||||||
if not ('@' in email and '.' in email):
|
|
||||||
raise newForumError("Invalid email", @["email"])
|
|
||||||
|
|
||||||
# perform registration:
|
# perform registration:
|
||||||
var salt = makeSalt()
|
var salt = makeSalt()
|
||||||
let password = makePassword(pass, salt)
|
let password = makePassword(pass, salt)
|
||||||
|
|
@ -1142,7 +1146,7 @@ proc executeRegister(c: TForumData, name, pass, antibot, userIp,
|
||||||
exec(db,
|
exec(db,
|
||||||
sql("INSERT INTO person(name, password, email, salt, status, lastOnline) " &
|
sql("INSERT INTO person(name, password, email, salt, status, lastOnline) " &
|
||||||
"VALUES (?, ?, ?, ?, ?, DATETIME('now'))"), name,
|
"VALUES (?, ?, ?, ?, ?, DATETIME('now'))"), name,
|
||||||
password, email, salt, $Moderated)
|
password, email, salt, $EmailUnconfirmed)
|
||||||
|
|
||||||
return password
|
return password
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,11 @@ $logo-height: $navbar-height - 20px;
|
||||||
a.visited {
|
a.visited {
|
||||||
color: lighten($body-font-color, 40%);
|
color: lighten($body-font-color, 40%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i {
|
||||||
|
// Icon
|
||||||
|
margin-right: $control-padding-x-sm;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$super-popular-color: #f86713;
|
$super-popular-color: #f86713;
|
||||||
|
|
|
||||||
|
|
@ -100,12 +100,17 @@ when defined(js):
|
||||||
tr(class=class({"no-border": noBorder})):
|
tr(class=class({"no-border": noBorder})):
|
||||||
td(class="thread-title"):
|
td(class="thread-title"):
|
||||||
if thread.isLocked:
|
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:
|
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:
|
if thread.isSolved:
|
||||||
italic(class="fas fa-check-square fa-xs")
|
italic(class="fas fa-check-square fa-xs",
|
||||||
a(href=makeUri("/t/" & $thread.id), onClick=anchorCB): text thread.topic
|
title="Thread has a solution")
|
||||||
|
a(href=makeUri("/t/" & $thread.id),
|
||||||
|
onClick=anchorCB):
|
||||||
|
text thread.topic
|
||||||
td():
|
td():
|
||||||
render(thread.category)
|
render(thread.category)
|
||||||
genUserAvatars(thread.users)
|
genUserAvatars(thread.users)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue