Skip to content

Commit eeef0f3

Browse files
author
zjj
committed
Merge branch 'main' of https://github.com/go-gitea/gitea
* 'main' of https://github.com/go-gitea/gitea: Fix EasyMDE image paste bug during refactoring (go-gitea#18207) Sort locales according to their names (go-gitea#18211) Restore setting of ctx.Repo.Mirror (go-gitea#18205) [skip ci] Updated translations via Crowdin Show OAuth callback error message (go-gitea#18185)
2 parents 65adde5 + 70d7475 commit eeef0f3

File tree

8 files changed

+75
-10
lines changed

8 files changed

+75
-10
lines changed

modules/context/repo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,14 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) {
366366

367367
if repo.IsMirror {
368368
var err error
369-
mirror, err := repo_model.GetMirrorByRepoID(repo.ID)
369+
ctx.Repo.Mirror, err = repo_model.GetMirrorByRepoID(repo.ID)
370370
if err != nil {
371371
ctx.ServerError("GetMirrorByRepoID", err)
372372
return
373373
}
374-
ctx.Data["MirrorEnablePrune"] = mirror.EnablePrune
375-
ctx.Data["MirrorInterval"] = mirror.Interval
376-
ctx.Data["Mirror"] = mirror
374+
ctx.Data["MirrorEnablePrune"] = ctx.Repo.Mirror.EnablePrune
375+
ctx.Data["MirrorInterval"] = ctx.Repo.Mirror.Interval
376+
ctx.Data["Mirror"] = ctx.Repo.Mirror
377377
}
378378

379379
pushMirrors, err := repo_model.GetPushMirrorsByRepoID(repo.ID)

modules/translation/translation.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
package translation
66

77
import (
8+
"sort"
9+
"strings"
10+
811
"code.gitea.io/gitea/modules/log"
912
"code.gitea.io/gitea/modules/options"
1013
"code.gitea.io/gitea/modules/setting"
@@ -31,7 +34,7 @@ var (
3134
supportedTags []language.Tag
3235
)
3336

34-
// AllLangs returns all supported langauages
37+
// AllLangs returns all supported languages sorted by name
3538
func AllLangs() []LangType {
3639
return allLangs
3740
}
@@ -72,6 +75,11 @@ func InitLocales() {
7275
for i, v := range langs {
7376
allLangs = append(allLangs, LangType{v, names[i]})
7477
}
78+
79+
// Sort languages case insensitive according to their name - needed for the user settings
80+
sort.Slice(allLangs, func(i, j int) bool {
81+
return strings.ToLower(allLangs[i].Name) < strings.ToLower(allLangs[j].Name)
82+
})
7583
}
7684

7785
// Match matches accept languages

options/locale/locale_en-US.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ oauth_signup_submit = Complete Account
317317
oauth_signin_tab = Link to Existing Account
318318
oauth_signin_title = Sign In to Authorize Linked Account
319319
oauth_signin_submit = Link Account
320+
oauth.signin.error = There was an error processing the authorization request. If this error persists, please contact the site administrator.
321+
oauth.signin.error.access_denied = The authorization request was denied.
322+
oauth.signin.error.temporarily_unavailable = Authorization failed because the authentication server is temporarily unavailable. Please try again later.
320323
openid_connect_submit = Connect
321324
openid_connect_title = Connect to an existing account
322325
openid_connect_desc = The chosen OpenID URI is unknown. Associate it with a new account here.

options/locale/locale_pt-PT.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ view_home=Ver %s
244244
search_repos=Procurar um repositório…
245245
filter=Outros filtros
246246
filter_by_team_repositories=Filtrar por repositórios da equipa
247+
feed_of=Fonte de "%s"
247248

248249
show_archived=Arquivado
249250
show_both_archived_unarchived=Apresentando arquivados e não arquivados
@@ -1435,6 +1436,8 @@ pulls.compare_changes=Novo pedido de integração
14351436
pulls.compare_changes_desc=Escolha o ramo de destino e o ramo de origem.
14361437
pulls.compare_base=integrar em
14371438
pulls.compare_compare=puxar de
1439+
pulls.switch_comparison_type=Trocar o tipo de comparação
1440+
pulls.switch_head_and_base=Trocar o topo com a base
14381441
pulls.filter_branch=Filtrar ramo
14391442
pulls.no_results=Não foram encontrados quaisquer resultados.
14401443
pulls.nothing_to_compare=Estes ramos são iguais. Não há necessidade de criar um pedido de integração.
@@ -2080,6 +2083,7 @@ diff.too_many_files=Alguns ficheiros não foram mostrados porque foram modificad
20802083
diff.show_more=Mostrar mais
20812084
diff.load=Carregar diff
20822085
diff.generated=gerado
2086+
diff.vendored=externo
20832087
diff.comment.placeholder=Deixar um comentário
20842088
diff.comment.markdown_info=A formatação com markdown é suportada.
20852089
diff.comment.add_single_comment=Adicionar um único comentário

options/locale/locale_zh-CN.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ commits.signed_by_untrusted_user_unmatched=由与提交者不匹配的未授信
10991099
commits.gpg_key_id=GPG 密钥 ID
11001100
commits.ssh_key_fingerprint=SSH 密钥指纹
11011101
1102+
ext_issues=访问外部工单
11021103
ext_issues.desc=链接到外部工单跟踪系统。
11031104
11041105
projects=项目
@@ -1578,6 +1579,7 @@ signing.wont_sign.commitssigned=合并将不会被签名,因为所有相关的
15781579
signing.wont_sign.approved=合并将不会被签名,因为合并请求未被批准
15791580
signing.wont_sign.not_signed_in=您还没有登录。
15801581
1582+
ext_wiki=访问外部百科
15811583
ext_wiki.desc=链接到外部 wiki。
15821584
15831585
wiki=百科
@@ -1834,6 +1836,8 @@ settings.webhook.response=响应内容
18341836
settings.webhook.headers=头信息
18351837
settings.webhook.payload=内容
18361838
settings.webhook.body=响应体
1839+
settings.webhook.replay.description=重放此 webhook。
1840+
settings.webhook.delivery.success=一个事件已被添加到推送队列。可能需要过几秒钟才会显示在推送记录中。
18371841
settings.githooks_desc=Git Hook 是 Git 本身提供的功能。您可以在下方编辑 hook 文件以设置自定义操作。
18381842
settings.githook_edit_desc=如果钩子未启动,则会显示样例文件中的内容。如果想要删除某个钩子,则提交空白文本即可。
18391843
settings.githook_name=钩子名称
@@ -2258,7 +2262,13 @@ teams.leave=离开团队
22582262
teams.leave.detail=离开 %s?
22592263
teams.can_create_org_repo=创建仓库
22602264
teams.can_create_org_repo_helper=成员可以在组织中创建仓库。创建者将自动获得创建的仓库的管理员权限。
2265+
teams.none_access=无访问权限
2266+
teams.none_access_helper=成员无法查看此单元或对其执行任何其他操作。
2267+
teams.general_access=常规访问
2268+
teams.general_access_helper=成员权限将由以下权限表决定。
2269+
teams.read_access=读取
22612270
teams.read_access_helper=成员可以查看和克隆团队仓库。
2271+
teams.write_access=写入
22622272
teams.write_access_helper=成员可以查看和推送提交到团队仓库。
22632273
teams.admin_access=管理员权限
22642274
teams.admin_access_helper=成员可以拉取和推送到团队仓库同时可以添加协作者。
@@ -2887,6 +2897,7 @@ error.probable_bad_signature=警告!虽然数据库中有一个此ID的密钥
28872897
error.probable_bad_default_signature=警告!虽然默认密钥拥有此ID,但它没有验证此提交!此提交是有疑问的。
28882898
28892899
[units]
2900+
unit=单元
28902901
error.no_unit_allowed_repo=您没有被允许访问此仓库的任何单元。
28912902
error.unit_not_allowed=您没有权限访问此仓库单元
28922903

routers/web/auth/oauth.go

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@ func (err AccessTokenError) Error() string {
106106
return fmt.Sprintf("%s: %s", err.ErrorCode, err.ErrorDescription)
107107
}
108108

109+
// errCallback represents a oauth2 callback error
110+
type errCallback struct {
111+
Code string
112+
Description string
113+
}
114+
115+
func (err errCallback) Error() string {
116+
return err.Description
117+
}
118+
109119
// TokenType specifies the kind of token
110120
type TokenType string
111121

@@ -810,7 +820,6 @@ func SignInOAuthCallback(ctx *context.Context) {
810820
}
811821

812822
u, gothUser, err := oAuth2UserLoginCallback(authSource, ctx.Req, ctx.Resp)
813-
814823
if err != nil {
815824
if user_model.IsErrUserProhibitLogin(err) {
816825
uplerr := err.(*user_model.ErrUserProhibitLogin)
@@ -819,6 +828,19 @@ func SignInOAuthCallback(ctx *context.Context) {
819828
ctx.HTML(http.StatusOK, "user/auth/prohibit_login")
820829
return
821830
}
831+
if callbackErr, ok := err.(errCallback); ok {
832+
log.Info("Failed OAuth callback: (%v) %v", callbackErr.Code, callbackErr.Description)
833+
switch callbackErr.Code {
834+
case "access_denied":
835+
ctx.Flash.Error(ctx.Tr("auth.oauth.signin.error.access_denied"))
836+
case "temporarily_unavailable":
837+
ctx.Flash.Error(ctx.Tr("auth.oauth.signin.error.temporarily_unavailable"))
838+
default:
839+
ctx.Flash.Error(ctx.Tr("auth.oauth.signin.error"))
840+
}
841+
ctx.Redirect(setting.AppSubURL + "/user/login")
842+
return
843+
}
822844
ctx.ServerError("UserSignIn", err)
823845
return
824846
}
@@ -1065,6 +1087,18 @@ func oAuth2UserLoginCallback(authSource *auth.Source, request *http.Request, res
10651087
log.Error("OAuth2 Provider %s returned too long a token. Current max: %d. Either increase the [OAuth2] MAX_TOKEN_LENGTH or reduce the information returned from the OAuth2 provider", authSource.Name, setting.OAuth2.MaxTokenLength)
10661088
err = fmt.Errorf("OAuth2 Provider %s returned too long a token. Current max: %d. Either increase the [OAuth2] MAX_TOKEN_LENGTH or reduce the information returned from the OAuth2 provider", authSource.Name, setting.OAuth2.MaxTokenLength)
10671089
}
1090+
// goth does not provide the original error message
1091+
// https://github.com/markbates/goth/issues/348
1092+
if strings.Contains(err.Error(), "server response missing access_token") || strings.Contains(err.Error(), "could not find a matching session for this request") {
1093+
errorCode := request.FormValue("error")
1094+
errorDescription := request.FormValue("error_description")
1095+
if errorCode != "" || errorDescription != "" {
1096+
return nil, goth.User{}, errCallback{
1097+
Code: errorCode,
1098+
Description: errorDescription,
1099+
}
1100+
}
1101+
}
10681102
return nil, goth.User{}, err
10691103
}
10701104

web_src/js/features/repo-issue.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,10 @@ export function initRepoPullRequestReview() {
458458

459459
const $reviewBox = $('.review-box');
460460
if ($reviewBox.length === 1) {
461-
createCommentEasyMDE($reviewBox.find('textarea'));
462-
initCompImagePaste($reviewBox);
461+
(async () => {
462+
await createCommentEasyMDE($reviewBox.find('textarea'));
463+
initCompImagePaste($reviewBox);
464+
})();
463465
}
464466

465467
// The following part is only for diff views

web_src/js/features/repo-legacy.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@ export function initRepoCommentForm() {
6464
});
6565
}
6666

67-
createCommentEasyMDE($('.comment.form textarea:not(.review-textarea)'));
67+
(async () => {
68+
await createCommentEasyMDE($('.comment.form textarea:not(.review-textarea)'));
69+
initCompImagePaste($('.comment.form'));
70+
})();
71+
6872
initBranchSelector();
6973
initCompMarkupContentPreviewTab($('.comment.form'));
70-
initCompImagePaste($('.comment.form'));
7174

7275
// List submits
7376
function initListSubmits(selector, outerSelector) {

0 commit comments

Comments
 (0)