Switch permissions around. EmailUnconfirmed's are now visible but cannot post.
This commit is contained in:
parent
2ab20bf7a5
commit
aa9f24e1d7
2 changed files with 22 additions and 1 deletions
|
|
@ -1020,6 +1020,13 @@ proc executeReply(c: TForumData, threadId: int, content: string,
|
||||||
# TODO: Refactor TForumData.
|
# TODO: Refactor TForumData.
|
||||||
assert c.loggedIn()
|
assert c.loggedIn()
|
||||||
|
|
||||||
|
if not canPost(c.rank):
|
||||||
|
case c.rank
|
||||||
|
of EmailUnconfirmed:
|
||||||
|
raise newForumError("You need to confirm your email before you can post")
|
||||||
|
else:
|
||||||
|
raise newForumError("You are not allowed to post")
|
||||||
|
|
||||||
if rateLimitCheck(c):
|
if rateLimitCheck(c):
|
||||||
raise newForumError("You're posting too fast!")
|
raise newForumError("You're posting too fast!")
|
||||||
|
|
||||||
|
|
@ -1097,6 +1104,13 @@ proc executeNewThread(c: TForumData, subject, msg: string): (int64, int64) =
|
||||||
|
|
||||||
assert c.loggedIn()
|
assert c.loggedIn()
|
||||||
|
|
||||||
|
if not canPost(c.rank):
|
||||||
|
case c.rank
|
||||||
|
of EmailUnconfirmed:
|
||||||
|
raise newForumError("You need to confirm your email before you can post")
|
||||||
|
else:
|
||||||
|
raise newForumError("You are not allowed to post")
|
||||||
|
|
||||||
if subject.len <= 2:
|
if subject.len <= 2:
|
||||||
raise newForumError("Subject is too short", @["subject"])
|
raise newForumError("Subject is too short", @["subject"])
|
||||||
if subject.len > 100:
|
if subject.len > 100:
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,12 @@ type
|
||||||
Spammer ## spammer: every post is invisible
|
Spammer ## spammer: every post is invisible
|
||||||
Troll ## troll: cannot write new posts
|
Troll ## troll: cannot write new posts
|
||||||
Banned ## A non-specific ban
|
Banned ## A non-specific ban
|
||||||
EmailUnconfirmed ## member with unconfirmed email address
|
|
||||||
Moderated ## new member: posts manually reviewed before everybody
|
Moderated ## new member: posts manually reviewed before everybody
|
||||||
## can see them
|
## can see them
|
||||||
|
EmailUnconfirmed ## member with unconfirmed email address. Their posts
|
||||||
|
## are visible, but cannot make new posts. This is so that
|
||||||
|
## when a user with existing posts changes their email,
|
||||||
|
## their posts don't disappear.
|
||||||
User ## Ordinary user
|
User ## Ordinary user
|
||||||
Moderator ## Moderator: can change a user's rank
|
Moderator ## Moderator: can change a user's rank
|
||||||
Admin ## Admin: can do everything
|
Admin ## Admin: can do everything
|
||||||
|
|
@ -24,6 +27,10 @@ proc isOnline*(user: User): bool =
|
||||||
proc `==`*(u1, u2: User): bool =
|
proc `==`*(u1, u2: User): bool =
|
||||||
u1.name == u2.name
|
u1.name == u2.name
|
||||||
|
|
||||||
|
proc canPost*(rank: Rank): bool =
|
||||||
|
## Determines whether the specified rank can make new posts.
|
||||||
|
rank >= Rank.User or rank == Moderated
|
||||||
|
|
||||||
when defined(js):
|
when defined(js):
|
||||||
include karax/prelude
|
include karax/prelude
|
||||||
import karaxutils
|
import karaxutils
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue