Skip to content

Commit 7bac74b

Browse files
committed
Merge branch 'main' into fix-latest-commit-ui
# Conflicts: # web_src/css/repo.css
2 parents 2050ea2 + 079a1ff commit 7bac74b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1141
-747
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ module.exports = {
674674
'no-this-before-super': [2],
675675
'no-throw-literal': [2],
676676
'no-undef-init': [2],
677-
'no-undef': [0],
677+
'no-undef': [2], // it is still needed by eslint & IDE to prompt undefined names in real time
678678
'no-undefined': [0],
679679
'no-underscore-dangle': [0],
680680
'no-unexpected-multiline': [2],

models/user/email_address.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ func VerifyActiveEmailCode(ctx context.Context, code, email string) *EmailAddres
357357
if user := GetVerifyUser(ctx, code); user != nil {
358358
// time limit code
359359
prefix := code[:base.TimeLimitCodeLength]
360-
data := fmt.Sprintf("%d%s%s%s%s", user.ID, email, user.LowerName, user.Passwd, user.Rands)
361-
360+
opts := &TimeLimitCodeOptions{Purpose: TimeLimitCodeActivateEmail, NewEmail: email}
361+
data := makeTimeLimitCodeHashData(opts, user)
362362
if base.VerifyTimeLimitCode(time.Now(), data, setting.Service.ActiveCodeLives, prefix) {
363363
emailAddress := &EmailAddress{UID: user.ID, Email: email}
364364
if has, _ := db.GetEngine(ctx).Get(emailAddress); has {
@@ -486,10 +486,10 @@ func ActivateUserEmail(ctx context.Context, userID int64, email string, activate
486486

487487
// Activate/deactivate a user's primary email address and account
488488
if addr.IsPrimary {
489-
user, exist, err := db.Get[User](ctx, builder.Eq{"id": userID, "email": email})
489+
user, exist, err := db.Get[User](ctx, builder.Eq{"id": userID})
490490
if err != nil {
491491
return err
492-
} else if !exist {
492+
} else if !exist || !strings.EqualFold(user.Email, email) {
493493
return fmt.Errorf("no user with ID: %d and Email: %s", userID, email)
494494
}
495495

models/user/user.go

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ func (u *User) BeforeUpdate() {
181181
u.MaxRepoCreation = -1
182182
}
183183

184-
// Organization does not need email
184+
// FIXME: this email doesn't need to be in lowercase, because the emails are mainly managed by the email table with lower_email field
185+
// This trick could be removed in new releases to display the user inputed email as-is.
185186
u.Email = strings.ToLower(u.Email)
186187
if !u.IsOrganization() {
187188
if len(u.AvatarEmail) == 0 {
@@ -310,17 +311,6 @@ func (u *User) OrganisationLink() string {
310311
return setting.AppSubURL + "/org/" + url.PathEscape(u.Name)
311312
}
312313

313-
// GenerateEmailActivateCode generates an activate code based on user information and given e-mail.
314-
func (u *User) GenerateEmailActivateCode(email string) string {
315-
code := base.CreateTimeLimitCode(
316-
fmt.Sprintf("%d%s%s%s%s", u.ID, email, u.LowerName, u.Passwd, u.Rands),
317-
setting.Service.ActiveCodeLives, time.Now(), nil)
318-
319-
// Add tail hex username
320-
code += hex.EncodeToString([]byte(u.LowerName))
321-
return code
322-
}
323-
324314
// GetUserFollowers returns range of user's followers.
325315
func GetUserFollowers(ctx context.Context, u, viewer *User, listOptions db.ListOptions) ([]*User, int64, error) {
326316
sess := db.GetEngine(ctx).
@@ -863,12 +853,38 @@ func GetVerifyUser(ctx context.Context, code string) (user *User) {
863853
return nil
864854
}
865855

866-
// VerifyUserActiveCode verifies active code when active account
867-
func VerifyUserActiveCode(ctx context.Context, code string) (user *User) {
856+
type TimeLimitCodePurpose string
857+
858+
const (
859+
TimeLimitCodeActivateAccount TimeLimitCodePurpose = "activate_account"
860+
TimeLimitCodeActivateEmail TimeLimitCodePurpose = "activate_email"
861+
TimeLimitCodeResetPassword TimeLimitCodePurpose = "reset_password"
862+
)
863+
864+
type TimeLimitCodeOptions struct {
865+
Purpose TimeLimitCodePurpose
866+
NewEmail string
867+
}
868+
869+
func makeTimeLimitCodeHashData(opts *TimeLimitCodeOptions, u *User) string {
870+
return fmt.Sprintf("%s|%d|%s|%s|%s|%s", opts.Purpose, u.ID, strings.ToLower(util.IfZero(opts.NewEmail, u.Email)), u.LowerName, u.Passwd, u.Rands)
871+
}
872+
873+
// GenerateUserTimeLimitCode generates a time-limit code based on user information and given e-mail.
874+
// TODO: need to use cache or db to store it to make sure a code can only be consumed once
875+
func GenerateUserTimeLimitCode(opts *TimeLimitCodeOptions, u *User) string {
876+
data := makeTimeLimitCodeHashData(opts, u)
877+
code := base.CreateTimeLimitCode(data, setting.Service.ActiveCodeLives, time.Now(), nil)
878+
code += hex.EncodeToString([]byte(u.LowerName)) // Add tail hex username
879+
return code
880+
}
881+
882+
// VerifyUserTimeLimitCode verifies the time-limit code
883+
func VerifyUserTimeLimitCode(ctx context.Context, opts *TimeLimitCodeOptions, code string) (user *User) {
868884
if user = GetVerifyUser(ctx, code); user != nil {
869885
// time limit code
870886
prefix := code[:base.TimeLimitCodeLength]
871-
data := fmt.Sprintf("%d%s%s%s%s", user.ID, user.Email, user.LowerName, user.Passwd, user.Rands)
887+
data := makeTimeLimitCodeHashData(opts, user)
872888
if base.VerifyTimeLimitCode(time.Now(), data, setting.Service.ActiveCodeLives, prefix) {
873889
return user
874890
}

options/locale/locale_cs-CZ.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ joined_on=Přidal/a se %s
647647
repositories=Repozitáře
648648
activity=Veřejná aktivita
649649
followers=Sledující
650+
show_more=Zobrazit více
650651
starred=Oblíbené repozitáře
651652
watched=Sledované repozitáře
652653
code=Kód

options/locale/locale_de-DE.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ joined_on=Beigetreten am %s
618618
repositories=Repositories
619619
activity=Öffentliche Aktivität
620620
followers=Follower
621+
show_more=Mehr anzeigen
621622
starred=Favoriten
622623
watched=Beobachtete Repositories
623624
code=Quelltext

options/locale/locale_el-GR.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ joined_on=Εγγράφηκε την %s
580580
repositories=Αποθετήρια
581581
activity=Δημόσια Δραστηριότητα
582582
followers=Ακόλουθοι
583+
show_more=Εμφάνιση Περισσότερων
583584
starred=Αγαπημένα Αποθετήρια
584585
watched=Ακολουθούμενα Αποθετήρια
585586
code=Κώδικας

options/locale/locale_es-ES.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ joined_on=Se unió el %s
577577
repositories=Repositorios
578578
activity=Actividad pública
579579
followers=Seguidores
580+
show_more=Ver más
580581
starred=Repositorios Favoritos
581582
watched=Repositorios seguidos
582583
code=Código

options/locale/locale_fa-IR.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ change_avatar=تغییر آواتار…
463463
repositories=مخازن
464464
activity=فعالیت های عمومی
465465
followers=دنبال کنندگان
466+
show_more=نمایش بیشتر
466467
starred=مخان ستاره دار
467468
watched=مخازنی که دنبال می‌شوند
468469
projects=پروژه‌ها

options/locale/locale_fr-FR.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ joined_on=Inscrit le %s
649649
repositories=Dépôts
650650
activity=Activité publique
651651
followers=abonnés
652+
show_more=Voir plus
652653
starred=Dépôts favoris
653654
watched=Dépôts surveillés
654655
code=Code

options/locale/locale_ga-IE.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ joined_on=Cláraigh ar %s
649649
repositories=Stórais
650650
activity=Gníomhaíocht Phoiblí
651651
followers=Leantóirí
652+
show_more=Taispeáin Tuilleadh
652653
starred=Stórais Réaltaithe
653654
watched=Stórais Breathnaithe
654655
code=Cód
@@ -1945,6 +1946,8 @@ pulls.delete.title=Scrios an t-iarratas tarraingthe seo?
19451946
pulls.delete.text=An bhfuil tú cinnte gur mhaith leat an t-iarratas tarraingthe seo a scriosadh? (Bainfidh sé seo an t-inneachar go léir go buan. Smaoinigh ar é a dhúnadh ina ionad sin, má tá sé i gceist agat é a choinneáil i gcartlann)
19461947

19471948
pulls.recently_pushed_new_branches=Bhrúigh tú ar bhrainse <strong>%[1]s</strong> %[2]s
1949+
pulls.upstream_diverging_prompt_behind_1=Tá an brainse seo %[1]d tiomantas taobh thiar de %[2]s
1950+
pulls.upstream_diverging_prompt_behind_n=Tá an brainse seo %[1]d geallta taobh thiar de %[2]s
19481951
pulls.upstream_diverging_prompt_base_newer=Tá athruithe nua ar an mbunbhrainse %s
19491952
pulls.upstream_diverging_merge=Forc sionc
19501953

@@ -3719,6 +3722,7 @@ runners.status.active=Gníomhach
37193722
runners.status.offline=As líne
37203723
runners.version=Leagan
37213724
runners.reset_registration_token=Athshocraigh comhartha clár
3725+
runners.reset_registration_token_confirm=Ar mhaith leat an comhartha reatha a neamhbhailiú agus ceann nua a ghiniúint?
37223726
runners.reset_registration_token_success=D'éirigh le hathshocrú comhartha clárúcháin an dara háit
37233727
37243728
runs.all_workflows=Gach Sreafaí Oibre
@@ -3770,6 +3774,8 @@ variables.creation.success=Tá an athróg "%s" curtha leis.
37703774
variables.update.failed=Theip ar athróg a chur in eagar.
37713775
variables.update.success=Tá an t-athróg curtha in eagar.
37723776

3777+
logs.always_auto_scroll=Logchomhaid scrollaithe uathoibríoch i gcónaí
3778+
logs.always_expand_running=Leathnaigh logs reatha i gcónaí
37733779

37743780
[projects]
37753781
deleted.display_name=Tionscadal scriosta

0 commit comments

Comments
 (0)