feat: add invites to backend
This commit is contained in:
parent
47ed36d24c
commit
6237ea940f
7 changed files with 234 additions and 30 deletions
|
@ -182,17 +182,18 @@ func (s *Server) discordSignup(w http.ResponseWriter, r *http.Request) error {
|
|||
}
|
||||
|
||||
if s.RequireInvite {
|
||||
// TODO: check invites, invalidate invite when done
|
||||
inviteValid := true
|
||||
|
||||
if !inviteValid {
|
||||
err = tx.Rollback(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "rolling back transaction")
|
||||
}
|
||||
valid, used, err := s.DB.InvalidateInvite(ctx, tx, req.InviteCode)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "checking and invalidating invite")
|
||||
}
|
||||
|
||||
if !valid {
|
||||
return server.APIError{Code: server.ErrInviteRequired}
|
||||
}
|
||||
|
||||
if used {
|
||||
return server.APIError{Code: server.ErrInviteAlreadyUsed}
|
||||
}
|
||||
}
|
||||
|
||||
// delete sign up ticket
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue