Merge pull request #199 from jyapayne/case_insensitive_usernames
Case insensitive usernames
This commit is contained in:
commit
bedaec3540
3 changed files with 23 additions and 8 deletions
|
|
@ -608,7 +608,7 @@ proc executeRegister(c: TForumData, name, pass, antibot, userIp,
|
||||||
raise newForumError("Invalid username", @["username"])
|
raise newForumError("Invalid username", @["username"])
|
||||||
if getValue(
|
if getValue(
|
||||||
db,
|
db,
|
||||||
sql"select name from person where name = ? and isDeleted = 0",
|
sql"select name from person where name = ? collate nocase and isDeleted = 0",
|
||||||
name
|
name
|
||||||
).len > 0:
|
).len > 0:
|
||||||
raise newForumError("Username already exists", @["username"])
|
raise newForumError("Username already exists", @["username"])
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ proc login*(session: Session, user, password: string) =
|
||||||
checkText "#profile-btn #profile-name", user
|
checkText "#profile-btn #profile-name", user
|
||||||
click "#profile-btn"
|
click "#profile-btn"
|
||||||
|
|
||||||
proc register*(session: Session, user, password: string) =
|
proc register*(session: Session, user, password: string, verify = true) =
|
||||||
with session:
|
with session:
|
||||||
click "#signup-btn"
|
click "#signup-btn"
|
||||||
|
|
||||||
|
|
@ -130,11 +130,13 @@ proc register*(session: Session, user, password: string) =
|
||||||
click "#signup-modal .create-account-btn"
|
click "#signup-modal .create-account-btn"
|
||||||
wait()
|
wait()
|
||||||
|
|
||||||
# Verify that the user menu has been initialised properly.
|
if verify:
|
||||||
click "#profile-btn"
|
with session:
|
||||||
checkText "#profile-btn #profile-name", user
|
# Verify that the user menu has been initialised properly.
|
||||||
# close menu
|
click "#profile-btn"
|
||||||
click "#profile-btn"
|
checkText "#profile-btn #profile-name", user
|
||||||
|
# close menu
|
||||||
|
click "#profile-btn"
|
||||||
|
|
||||||
proc createThread*(session: Session, title, content: string) =
|
proc createThread*(session: Session, title, content: string) =
|
||||||
with session:
|
with session:
|
||||||
|
|
|
||||||
|
|
@ -30,5 +30,18 @@ proc test*(session: Session, baseUrl: string) =
|
||||||
test "can register":
|
test "can register":
|
||||||
with session:
|
with session:
|
||||||
register("test", "test")
|
register("test", "test")
|
||||||
|
logout()
|
||||||
|
|
||||||
session.logout()
|
test "can't register same username with different case":
|
||||||
|
with session:
|
||||||
|
register "test1", "test1", verify = false
|
||||||
|
logout()
|
||||||
|
|
||||||
|
navigate baseUrl
|
||||||
|
wait()
|
||||||
|
|
||||||
|
register "TEst1", "test1", verify = false
|
||||||
|
|
||||||
|
ensureExists "#signup-form .has-error"
|
||||||
|
navigate baseUrl
|
||||||
|
wait()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue