mirror of https://github.com/go-gitea/gitea
parent
0d9b2f3860
commit
46687f391c
@ -0,0 +1,54 @@ |
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package user |
||||
|
||||
import ( |
||||
"github.com/gogits/gogs/models" |
||||
"github.com/gogits/gogs/modules/auth" |
||||
"github.com/gogits/gogs/modules/base" |
||||
"github.com/gogits/gogs/modules/log" |
||||
"github.com/martini-contrib/render" |
||||
"github.com/martini-contrib/sessions" |
||||
"net/http" |
||||
) |
||||
|
||||
func Setting(r render.Render, data base.TmplData, session sessions.Session) { |
||||
data["Title"] = "Setting" |
||||
data["PageIsUserSetting"] = true |
||||
r.HTML(200, "user/setting", data) |
||||
} |
||||
|
||||
func SettingSSHKeys(r render.Render, data base.TmplData, req *http.Request, session sessions.Session) { |
||||
// add ssh key
|
||||
if req.Method == "POST" { |
||||
k := &models.PublicKey{OwnerId: auth.SignedInId(session), |
||||
Name: req.FormValue("keyname"), |
||||
Content: req.FormValue("key_content"), |
||||
} |
||||
err := models.AddPublicKey(k) |
||||
if err != nil { |
||||
data["ErrorMsg"] = err |
||||
log.Error("ssh.AddPublicKey: %v", err) |
||||
r.HTML(200, "base/error", data) |
||||
return |
||||
} else { |
||||
data["AddSSHKeySuccess"] = true |
||||
} |
||||
} |
||||
// get keys
|
||||
keys, err := models.ListPublicKey(auth.SignedInId(session)) |
||||
if err != nil { |
||||
data["ErrorMsg"] = err |
||||
log.Error("ssh.ListPublicKey: %v", err) |
||||
r.HTML(200, "base/error", data) |
||||
return |
||||
} |
||||
|
||||
// set to template
|
||||
data["Title"] = "SSH Keys" |
||||
data["PageIsUserSetting"] = true |
||||
data["Keys"] = keys |
||||
r.HTML(200, "user/publickey", data) |
||||
} |
@ -0,0 +1,62 @@ |
||||
{{template "base/head" .}} |
||||
{{template "base/navbar" .}} |
||||
<div id="gogs-body" class="container"> |
||||
<div id="gogs-user-setting-nav" class="col-md-3"> |
||||
<h4>Account Setting</h4> |
||||
<ul class="list-group"> |
||||
<li class="list-group-item"><a href="/user/setting">Account Profile</a></li> |
||||
<li class="list-group-item"><a href="#">Emails and Password</a></li> |
||||
<li class="list-group-item"><a href="#">Notifications</a></li> |
||||
<li class="list-group-item list-group-item-success"><a href="/user/setting/ssh/">SSH Keys</a></li> |
||||
<li class="list-group-item"><a href="#">Security</a></li> |
||||
<li class="list-group-item"><a href="#">Kill Myself</a></li> |
||||
</ul> |
||||
</div> |
||||
<div id="gogs-user-setting-container" class="col-md-9"> |
||||
<div id="gogs-ssh-keys"> |
||||
<h4>SSH Keys</h4>{{if .AddSSHKeySuccess}} |
||||
<p class="alert alert-success">New SSH Key is added !</p>{{end}} |
||||
<ul id="gogs-ssh-keys-list" class="list-group"> |
||||
<li class="list-group-item"><span class="name">SSH Key's name</span></li>{{range .Keys}} |
||||
<li class="list-group-item"> |
||||
<span class="name">{{.Name}}</span> |
||||
<span class="print">(print code)</span> |
||||
<a href="#" class="btn btn-link btn-danger right delete" rel="{{.Id}}" data-del="{{.Id}}">Delete</a> |
||||
</li>{{end}} |
||||
<li class="list-group-item"> |
||||
<a class="btn btn-link btn-primary" href="#ssh-add-modal" id="gogs-ssh-add" data-toggle="modal">Add SSH Key</a> |
||||
</li> |
||||
</ul> |
||||
<div class="modal fade" id="ssh-add-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> |
||||
<div class="modal-dialog"> |
||||
<form class="modal-content form-horizontal" id="gogs-ssh-form" method="post" action="/user/setting/ssh/"> |
||||
<div class="modal-header"> |
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> |
||||
<h4 class="modal-title" id="myModalLabel">Add SSH Key</h4> |
||||
</div> |
||||
<div class="modal-body"> |
||||
<div class="form-group"> |
||||
<label class="col-md-3 control-label">The name of key<strong class="text-danger">*</strong></label> |
||||
<div class="col-md-8"> |
||||
<input name="keyname" class="form-control" placeholder="Type your preferred name" required="required"> |
||||
</div> |
||||
</div> |
||||
<div class="form-group"> |
||||
<label class="col-md-3 control-label">SSH Key<strong class="text-danger">*</strong></label> |
||||
<div class="col-md-8"> |
||||
<textarea name="key_content" class="form-control" placeholder="Type your key content" required="required"></textarea> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="modal-footer"> |
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
||||
<button type="submit" class="btn btn-primary">Save changes</button> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
</div> |
||||
<p><strong>Need help?</strong> Check out our guide to <a href="https://help.github.com/articles/generating-ssh-keys" target="_blank">generating SSH keys</a> or troubleshoot <a href="https://help.github.com/ssh-issues/" target="_blank">common SSH Problems</a></p> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
{{template "base/footer" .}} |
@ -0,0 +1,19 @@ |
||||
{{template "base/head" .}} |
||||
{{template "base/navbar" .}} |
||||
<div id="gogs-body" class="container"> |
||||
<div id="gogs-user-setting-nav" class="col-md-3"> |
||||
<h4>Account Setting</h4> |
||||
<ul class="list-group"> |
||||
<li class="list-group-item list-group-item-success"><a href="/user/setting">Account Profile</a></li> |
||||
<li class="list-group-item"><a href="#">Emails and Password</a></li> |
||||
<li class="list-group-item"><a href="#">Notifications</a></li> |
||||
<li class="list-group-item"><a href="/user/setting/ssh/">SSH Keys</a></li> |
||||
<li class="list-group-item"><a href="#">Security</a></li> |
||||
<li class="list-group-item"><a href="#">Kill myself</a></li> |
||||
</ul> |
||||
</div> |
||||
<div id="gogs-user-setting-container" class="col-md-9"> |
||||
setting container |
||||
</div> |
||||
</div> |
||||
{{template "base/footer" .}} |
Loading…
Reference in new issue