feat(invite): more progress on invited / sigup view, #2353
This commit is contained in:
+4
-1
@@ -22,7 +22,7 @@ func Register(r *macaron.Macaron) {
|
||||
r.Post("/login", bind(dtos.LoginCommand{}), wrap(LoginPost))
|
||||
r.Get("/login/:name", OAuthLogin)
|
||||
r.Get("/login", LoginView)
|
||||
r.Get("/signup/invited", Index)
|
||||
r.Get("/invite", Index)
|
||||
|
||||
// authed views
|
||||
r.Get("/profile/", reqSignedIn, Index)
|
||||
@@ -43,6 +43,9 @@ func Register(r *macaron.Macaron) {
|
||||
r.Get("/signup", Index)
|
||||
r.Post("/api/user/signup", bind(m.CreateUserCommand{}), wrap(SignUp))
|
||||
|
||||
// invited
|
||||
r.Get("/api/user/invite/:code", wrap(GetInviteInfoByCode))
|
||||
|
||||
// reset password
|
||||
r.Get("/user/password/send-reset-email", Index)
|
||||
r.Get("/user/password/reset", Index)
|
||||
|
||||
@@ -8,3 +8,9 @@ type AddInviteForm struct {
|
||||
Role m.RoleType `json:"role" binding:"Required"`
|
||||
SkipEmails bool `json:"skipEmails"`
|
||||
}
|
||||
|
||||
type InviteInfo struct {
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
@@ -96,3 +96,22 @@ func RevokeInvite(c *middleware.Context) Response {
|
||||
|
||||
return ApiSuccess("Invite revoked")
|
||||
}
|
||||
|
||||
func GetInviteInfoByCode(c *middleware.Context) Response {
|
||||
query := m.GetTempUsersByCodeQuery{Code: c.Params(":code")}
|
||||
|
||||
if err := bus.Dispatch(&query); err != nil {
|
||||
if err == m.ErrTempUserNotFound {
|
||||
return ApiError(404, "Invite not found", nil)
|
||||
}
|
||||
return ApiError(500, "Failed to get invite", err)
|
||||
}
|
||||
|
||||
info := dtos.InviteInfo{
|
||||
Email: query.Result.Email,
|
||||
Name: query.Result.Name,
|
||||
Username: query.Result.Email,
|
||||
}
|
||||
|
||||
return Json(200, &info)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user