mirror of
https://github.com/thomiceli/opengist.git
synced 2025-06-13 13:57:13 +02:00
Style preference tab for user (#467)
This commit is contained in:
@ -20,7 +20,7 @@ func SshKeysProcess(ctx *context.Context) error {
|
||||
|
||||
if err := ctx.Validate(dto); err != nil {
|
||||
ctx.AddFlash(validator.ValidationMessages(&err, ctx.GetData("locale").(*i18n.Locale)), "error")
|
||||
return ctx.RedirectTo("/settings")
|
||||
return ctx.RedirectTo("/settings/ssh")
|
||||
}
|
||||
key := dto.ToSSHKey()
|
||||
|
||||
@ -29,7 +29,7 @@ func SshKeysProcess(ctx *context.Context) error {
|
||||
pubKey, _, _, _, err := ssh.ParseAuthorizedKey([]byte(key.Content))
|
||||
if err != nil {
|
||||
ctx.AddFlash(ctx.Tr("flash.user.invalid-ssh-key"), "error")
|
||||
return ctx.RedirectTo("/settings")
|
||||
return ctx.RedirectTo("/settings/ssh")
|
||||
}
|
||||
key.Content = strings.TrimSpace(string(ssh.MarshalAuthorizedKey(pubKey)))
|
||||
|
||||
@ -38,7 +38,7 @@ func SshKeysProcess(ctx *context.Context) error {
|
||||
return ctx.ErrorRes(500, "Cannot check if SSH key exists", err)
|
||||
}
|
||||
ctx.AddFlash(ctx.Tr("settings.ssh-key-exists"), "error")
|
||||
return ctx.RedirectTo("/settings")
|
||||
return ctx.RedirectTo("/settings/ssh")
|
||||
}
|
||||
|
||||
if err := key.Create(); err != nil {
|
||||
@ -46,20 +46,20 @@ func SshKeysProcess(ctx *context.Context) error {
|
||||
}
|
||||
|
||||
ctx.AddFlash(ctx.Tr("flash.user.ssh-key-added"), "success")
|
||||
return ctx.RedirectTo("/settings")
|
||||
return ctx.RedirectTo("/settings/ssh")
|
||||
}
|
||||
|
||||
func SshKeysDelete(ctx *context.Context) error {
|
||||
user := ctx.User
|
||||
keyId, err := strconv.Atoi(ctx.Param("id"))
|
||||
if err != nil {
|
||||
return ctx.RedirectTo("/settings")
|
||||
return ctx.RedirectTo("/settings/ssh")
|
||||
}
|
||||
|
||||
key, err := db.GetSSHKeyByID(uint(keyId))
|
||||
|
||||
if err != nil || key.UserID != user.ID {
|
||||
return ctx.RedirectTo("/settings")
|
||||
return ctx.RedirectTo("/settings/ssh")
|
||||
}
|
||||
|
||||
if err := key.Delete(); err != nil {
|
||||
@ -67,5 +67,5 @@ func SshKeysDelete(ctx *context.Context) error {
|
||||
}
|
||||
|
||||
ctx.AddFlash(ctx.Tr("flash.user.ssh-key-deleted"), "success")
|
||||
return ctx.RedirectTo("/settings")
|
||||
return ctx.RedirectTo("/settings/ssh")
|
||||
}
|
||||
|
Reference in New Issue
Block a user