diff --git a/models/user/email_address.go b/models/user/email_address.go index 71b96c00be..5c04909ed7 100644 --- a/models/user/email_address.go +++ b/models/user/email_address.go @@ -395,6 +395,7 @@ type SearchEmailOptions struct { // SearchEmailResult is an e-mail address found in the user or email_address table type SearchEmailResult struct { + ID int64 UID int64 Email string IsActivated bool diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 746288bb9a..6a748aed00 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2982,6 +2982,10 @@ emails.not_updated = Failed to update the requested email address: %v emails.duplicate_active = This email address is already active for a different user. emails.change_email_header = Update Email Properties emails.change_email_text = Are you sure you want to update this email address? +emails.delete = Delete Email +emails.delete_desc = Are you sure you want to delete this email address? +emails.deletion_success = The email address has been deleted. +emails.delete_primary_email_error = You can not delete the primary email. orgs.org_manage_panel = Organization Management orgs.name = Name diff --git a/options/locale/locale_ja-JP.ini b/options/locale/locale_ja-JP.ini index 2cdae3e47d..7d552ad84c 100644 --- a/options/locale/locale_ja-JP.ini +++ b/options/locale/locale_ja-JP.ini @@ -477,6 +477,7 @@ activate_email=メール アドレスを確認します activate_email.title=%s さん、メールアドレス確認をお願いします activate_email.text=あなたのメールアドレスを確認するため、%s以内に次のリンクをクリックしてください: +register_notify=%s へようこそ register_notify.title=%[1]s さん、%[2]s にようこそ register_notify.text_1=これは %s への登録確認メールです! register_notify.text_2=あなたはユーザー名 %s でログインできるようになりました。 @@ -913,6 +914,7 @@ create_oauth2_application_success=新しいOAuth2アプリケーションを作 update_oauth2_application_success=OAuth2アプリケーションを更新しました。 oauth2_application_name=アプリケーション名 oauth2_confidential_client=コンフィデンシャルクライアント。 ウェブアプリのように秘密情報を機密にできるアプリの場合に選択します。 デスクトップアプリやモバイルアプリなどのネイティブアプリには選択しないでください。 +oauth2_skip_secondary_authorization=一度アクセスを許可した後、公開クライアントの認証をスキップします。 セキュリティ上のリスクが生じる可能性があります。 oauth2_redirect_uris=リダイレクトURI (複数可)。 URIごとに改行してください。 save_application=保存 oauth2_client_id=クライアントID diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index 42483291fc..e335c29c70 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -42,7 +42,7 @@ func GetRawFile(ctx *context.APIContext) { // --- // summary: Get a file from a repository // produces: - // - application/json + // - application/octet-stream // parameters: // - name: owner // in: path @@ -67,6 +67,8 @@ func GetRawFile(ctx *context.APIContext) { // responses: // 200: // description: Returns raw file content. + // schema: + // type: file // "404": // "$ref": "#/responses/notFound" @@ -92,6 +94,8 @@ func GetRawFileOrLFS(ctx *context.APIContext) { // swagger:operation GET /repos/{owner}/{repo}/media/{filepath} repository repoGetRawFileOrLFS // --- // summary: Get a file or it's LFS object from a repository + // produces: + // - application/octet-stream // parameters: // - name: owner // in: path @@ -116,6 +120,8 @@ func GetRawFileOrLFS(ctx *context.APIContext) { // responses: // 200: // description: Returns raw file content. + // schema: + // type: file // "404": // "$ref": "#/responses/notFound" diff --git a/routers/web/admin/emails.go b/routers/web/admin/emails.go index 2cf4035c6a..f0d8555070 100644 --- a/routers/web/admin/emails.go +++ b/routers/web/admin/emails.go @@ -15,6 +15,7 @@ import ( "code.gitea.io/gitea/modules/optional" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/services/context" + "code.gitea.io/gitea/services/user" ) const ( @@ -150,3 +151,32 @@ func ActivateEmail(ctx *context.Context) { redirect.RawQuery = q.Encode() ctx.Redirect(redirect.String()) } + +// DeleteEmail serves a POST request for delete a user's email +func DeleteEmail(ctx *context.Context) { + u, err := user_model.GetUserByID(ctx, ctx.FormInt64("Uid")) + if err != nil || u == nil { + ctx.ServerError("GetUserByID", err) + return + } + + email, err := user_model.GetEmailAddressByID(ctx, u.ID, ctx.FormInt64("id")) + if err != nil || email == nil { + ctx.ServerError("GetEmailAddressByID", err) + return + } + + if err := user.DeleteEmailAddresses(ctx, u, []string{email.Email}); err != nil { + if user_model.IsErrPrimaryEmailCannotDelete(err) { + ctx.Flash.Error(ctx.Tr("admin.emails.delete_primary_email_error")) + ctx.JSONRedirect("") + return + } + ctx.ServerError("DeleteEmailAddresses", err) + return + } + log.Trace("Email address deleted: %s %s", u.Name, email.Email) + + ctx.Flash.Success(ctx.Tr("admin.emails.deletion_success")) + ctx.JSONRedirect("") +} diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go index 204248d63f..7988dc96a4 100644 --- a/routers/web/auth/oauth.go +++ b/routers/web/auth/oauth.go @@ -353,8 +353,9 @@ func IntrospectOAuth(ctx *context.Context) { } var response struct { - Active bool `json:"active"` - Scope string `json:"scope,omitempty"` + Active bool `json:"active"` + Scope string `json:"scope,omitempty"` + Username string `json:"username,omitempty"` jwt.RegisteredClaims } @@ -371,6 +372,9 @@ func IntrospectOAuth(ctx *context.Context) { response.Audience = []string{app.ClientID} response.Subject = fmt.Sprint(grant.UserID) } + if user, err := user_model.GetUserByID(ctx, grant.UserID); err == nil { + response.Username = user.Name + } } } diff --git a/routers/web/feed/convert.go b/routers/web/feed/convert.go index cb62858631..774644e29a 100644 --- a/routers/web/feed/convert.go +++ b/routers/web/feed/convert.go @@ -83,7 +83,7 @@ func feedActionsToFeedItems(ctx *context.Context, actions activities_model.Actio link := &feeds.Link{Href: act.GetCommentHTMLURL(ctx)} // title - title = act.ActUser.DisplayName() + " " + title = act.ActUser.GetDisplayName() + " " var titleExtra template.HTML switch act.OpType { case activities_model.ActionCreateRepo: @@ -252,7 +252,7 @@ func feedActionsToFeedItems(ctx *context.Context, actions activities_model.Actio Description: desc, IsPermaLink: "false", Author: &feeds.Author{ - Name: act.ActUser.DisplayName(), + Name: act.ActUser.GetDisplayName(), Email: act.ActUser.GetEmail(), }, Id: fmt.Sprintf("%v: %v", strconv.FormatInt(act.ID, 10), link.Href), @@ -313,7 +313,7 @@ func releasesToFeedItems(ctx *context.Context, releases []*repo_model.Release) ( Link: link, Created: rel.CreatedUnix.AsTime(), Author: &feeds.Author{ - Name: rel.Publisher.DisplayName(), + Name: rel.Publisher.GetDisplayName(), Email: rel.Publisher.GetEmail(), }, Id: fmt.Sprintf("%v: %v", strconv.FormatInt(rel.ID, 10), link.Href), diff --git a/routers/web/web.go b/routers/web/web.go index d08e8da772..0e16c1ca6c 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -725,6 +725,7 @@ func registerRoutes(m *web.Router) { m.Group("/emails", func() { m.Get("", admin.Emails) m.Post("/activate", admin.ActivateEmail) + m.Post("/delete", admin.DeleteEmail) }) m.Group("/orgs", func() { diff --git a/templates/admin/emails/list.tmpl b/templates/admin/emails/list.tmpl index 1f226afcc4..93fbb9dfc2 100644 --- a/templates/admin/emails/list.tmpl +++ b/templates/admin/emails/list.tmpl @@ -38,6 +38,7 @@