mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 15:54:01 +01:00
Fix #652
This commit is contained in:
parent
dc53270da9
commit
1b66600bd0
4 changed files with 36 additions and 29 deletions
|
@ -8,7 +8,7 @@ github.com/Unknwon/cae = commit:2e70a1351b
|
|||
github.com/Unknwon/com = commit:2cbcbc6916
|
||||
github.com/Unknwon/goconfig = commit:0f8d8dc1c0
|
||||
github.com/Unknwon/i18n = commit:aec5f77857
|
||||
github.com/Unknwon/macaron = commit:5c8d1b7642
|
||||
github.com/Unknwon/macaron =
|
||||
github.com/codegangsta/cli = commit:7381bc4e62
|
||||
github.com/go-sql-driver/mysql = commit:8111ee3ec3
|
||||
github.com/go-xorm/core = commit:3e0fa232ab
|
||||
|
@ -20,7 +20,7 @@ github.com/macaron-contrib/binding = commit:0e23661e7d
|
|||
github.com/macaron-contrib/cache = commit:0bb9e6c9ef
|
||||
github.com/macaron-contrib/captcha = commit:3567dc48b8
|
||||
github.com/macaron-contrib/csrf = commit:422b79675c
|
||||
github.com/macaron-contrib/i18n = commit:2246f45894
|
||||
github.com/macaron-contrib/i18n =
|
||||
github.com/macaron-contrib/session = commit:f00d48fd4f
|
||||
github.com/macaron-contrib/toolbox = commit:57127bcc89
|
||||
github.com/mattn/go-sqlite3 = commit:a80c27ba33
|
||||
|
|
|
@ -89,6 +89,11 @@ type PublicKey struct {
|
|||
HasUsed bool `xorm:"-"`
|
||||
}
|
||||
|
||||
// OmitEmail returns content of public key but without e-mail address.
|
||||
func (k *PublicKey) OmitEmail() string {
|
||||
return strings.Join(strings.Split(k.Content, " ")[:2], " ")
|
||||
}
|
||||
|
||||
// GetAuthorizedString generates and returns formatted public key string for authorized_keys file.
|
||||
func (key *PublicKey) GetAuthorizedString() string {
|
||||
return fmt.Sprintf(_TPL_PUBLICK_KEY, appPath, key.Id, key.Content)
|
||||
|
|
|
@ -243,7 +243,7 @@ func IsRepositoryExist(u *User, repoName string) (bool, error) {
|
|||
|
||||
var (
|
||||
illegalEquals = []string{"debug", "raw", "install", "api", "avatar", "user", "org", "help", "stars", "issues", "pulls", "commits", "repo", "template", "admin", "new"}
|
||||
illegalSuffixs = []string{".git"}
|
||||
illegalSuffixs = []string{".git", ".keys"}
|
||||
)
|
||||
|
||||
// IsLegalName returns false if name contains illegal characters.
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Unknwon/com"
|
||||
|
||||
|
@ -127,6 +129,20 @@ func Pulls(ctx *middleware.Context) {
|
|||
ctx.HTML(200, PULLS)
|
||||
}
|
||||
|
||||
func ShowSSHKeys(ctx *middleware.Context, uid int64) {
|
||||
keys, err := models.ListPublicKeys(uid)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "ListPublicKeys", err)
|
||||
return
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
for i := range keys {
|
||||
buf.WriteString(keys[i].OmitEmail())
|
||||
}
|
||||
ctx.RenderData(200, buf.Bytes())
|
||||
}
|
||||
|
||||
func Profile(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Profile"
|
||||
ctx.Data["PageIsUserProfile"] = true
|
||||
|
@ -138,6 +154,12 @@ func Profile(ctx *middleware.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
isShowKeys := false
|
||||
if strings.HasSuffix(uname, ".keys") {
|
||||
isShowKeys = true
|
||||
uname = strings.TrimSuffix(uname, ".keys")
|
||||
}
|
||||
|
||||
u, err := models.GetUserByName(uname)
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
|
@ -148,6 +170,12 @@ func Profile(ctx *middleware.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// Show SSH keys.
|
||||
if isShowKeys {
|
||||
ShowSSHKeys(ctx, u.Id)
|
||||
return
|
||||
}
|
||||
|
||||
if u.IsOrganization() {
|
||||
ctx.Redirect(setting.AppSubUrl + "/org/" + u.Name)
|
||||
return
|
||||
|
@ -204,32 +232,6 @@ func Email2User(ctx *middleware.Context) {
|
|||
ctx.Redirect(setting.AppSubUrl + "/user/" + u.Name)
|
||||
}
|
||||
|
||||
const (
|
||||
TPL_FEED = `<i class="icon fa fa-%s"></i>
|
||||
<div class="info"><span class="meta">%s</span><br>%s</div>`
|
||||
)
|
||||
|
||||
// func Feeds(ctx *middleware.Context, form auth.FeedsForm) {
|
||||
// actions, err := models.GetFeeds(form.UserId, form.Page*20, false)
|
||||
// if err != nil {
|
||||
// ctx.JSON(500, err)
|
||||
// return
|
||||
// }
|
||||
|
||||
// feeds := make([]string, 0, len(actions))
|
||||
// for _, act := range actions {
|
||||
// if act.IsPrivate {
|
||||
// if has, _ := models.HasAccess(ctx.User.Name, act.RepoUserName+"/"+act.RepoName,
|
||||
// models.READABLE); !has {
|
||||
// continue
|
||||
// }
|
||||
// }
|
||||
// feeds = append(feeds, fmt.Sprintf(TPL_FEED, base.ActionIcon(act.OpType),
|
||||
// base.TimeSince(act.Created), base.ActionDesc(act)))
|
||||
// }
|
||||
// ctx.JSON(200, &feeds)
|
||||
// }
|
||||
|
||||
func Issues(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Your Issues"
|
||||
|
||||
|
|
Loading…
Reference in a new issue