MCPcopy Create free account
hub / github.com/gogs/gogs / ApplicationsPost

Method ApplicationsPost

internal/route/user/setting.go:606–638  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

604}
605
606func (h *SettingsHandler) ApplicationsPost() macaron.Handler {
607 return func(c *context.Context, f form.NewAccessToken) {
608 c.Title("settings.applications")
609 c.PageIs("SettingsApplications")
610
611 if c.HasError() {
612 tokens, err := h.store.ListAccessTokens(c.Req.Context(), c.User.ID)
613 if err != nil {
614 c.Errorf(err, "list access tokens")
615 return
616 }
617
618 c.Data["Tokens"] = tokens
619 c.HTML(http.StatusBadRequest, tmplUserSettingsApplications)
620 return
621 }
622
623 t, err := h.store.CreateAccessToken(c.Req.Context(), c.User.ID, f.Name)
624 if err != nil {
625 if database.IsErrAccessTokenAlreadyExist(err) {
626 c.Flash.Error(c.Tr("settings.token_name_exists"))
627 c.RedirectSubpath("/user/settings/applications")
628 } else {
629 c.Errorf(err, "new access token")
630 }
631 return
632 }
633
634 c.Flash.Success(c.Tr("settings.generate_token_succees"))
635 c.Flash.Info(t.Sha1)
636 c.RedirectSubpath("/user/settings/applications")
637 }
638}
639
640func (h *SettingsHandler) DeleteApplication() macaron.Handler {
641 return func(c *context.Context) {

Callers 1

runWebFunction · 0.95

Calls 12

TitleMethod · 0.80
PageIsMethod · 0.80
HasErrorMethod · 0.80
HTMLMethod · 0.80
TrMethod · 0.80
RedirectSubpathMethod · 0.80
SuccessMethod · 0.80
ListAccessTokensMethod · 0.65
CreateAccessTokenMethod · 0.65
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected