SignupInvitedPage: Show orgName (#94940)

* no orgname

* format code

* update unit test

* delete contextSrv

* fix unit test

* run prettier

---------

Co-authored-by: Laura Benz <laura.benz@grafana.com>
This commit is contained in:
jackyin
2024-10-23 16:49:27 +03:00
committed by GitHub
co-authored by Laura Benz
parent 022297f359
commit 008c51b5b1
4 changed files with 21 additions and 4 deletions
+1
View File
@@ -17,6 +17,7 @@ type InviteInfo struct {
Name string `json:"name"`
Username string `json:"username"`
InvitedBy string `json:"invitedBy"`
OrgName string `json:"orgName"`
}
type CompleteInviteForm struct {
+11
View File
@@ -220,11 +220,22 @@ func (hs *HTTPServer) GetInviteInfoByCode(c *contextmodel.ReqContext) response.R
return response.Error(http.StatusNotFound, "Invite not found", nil)
}
orgResult, err := hs.orgService.GetByID(c.Req.Context(), &org.GetOrgByIDQuery{
ID: invite.OrgID,
})
if err != nil {
if errors.Is(err, org.ErrOrgNotFound) {
return response.Error(http.StatusNotFound, "org not found", nil)
}
return response.Error(http.StatusInternalServerError, "Failed to get org", err)
}
return response.JSON(http.StatusOK, dtos.InviteInfo{
Email: invite.Email,
Name: invite.Name,
Username: invite.Email,
InvitedBy: util.StringsFallback3(invite.InvitedByName, invite.InvitedByLogin, invite.InvitedByEmail),
OrgName: orgResult.Name,
})
}