minor login work
This commit is contained in:
parent
c6ededd3d3
commit
d87901b122
3
main.go
3
main.go
|
@ -53,7 +53,6 @@ func loadConfig() {
|
|||
|
||||
func dbConnect() {
|
||||
var err error
|
||||
fmt.Println(fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=require", config.Sql.Username, config.Sql.Password, config.Sql.Host, config.Sql.Dbname))
|
||||
db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=require", config.Sql.Username, config.Sql.Password, config.Sql.Host, config.Sql.Dbname))
|
||||
|
||||
if err != nil {
|
||||
|
@ -90,7 +89,7 @@ func main() {
|
|||
initTemplates()
|
||||
init_route_handlers()
|
||||
|
||||
fmt.Println("Running...")
|
||||
fmt.Println("Listening on", config.Port, "...")
|
||||
err := http.ListenAndServe(":"+config.Port, nil)
|
||||
if err != nil {
|
||||
fmt.Println("Fatal Error: ", err)
|
||||
|
|
|
@ -34,7 +34,7 @@ func userHandler(next func(http.ResponseWriter, *http.Request, *user.User)) func
|
|||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
user, _ := initSessionUser(r)
|
||||
if user == nil {
|
||||
http.Redirect(w, r, "/", http.StatusFound)
|
||||
http.Redirect(w, r, "/login", http.StatusFound)
|
||||
} else {
|
||||
next(w, r, user)
|
||||
}
|
||||
|
|
|
@ -26,20 +26,16 @@
|
|||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/">MasterTracker</a>
|
||||
<a class="navbar-brand" href="/">transmet</a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<!--<li class="active"><a href="#">Home</a></li>
|
||||
<li><a href="#about">About</a></li>
|
||||
<li><a href="#contact">Contact</a></li> -->
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{{if .user}}
|
||||
<li><a href="/user/edit">{{.user.Displayname}}</a></li>
|
||||
<li>{{.user.Username}}</li>
|
||||
<li><a href="/logout">Logout</a></li>
|
||||
{{else}}
|
||||
<li><a href="/signup">Sign up</a></li>
|
||||
<li><a href="/login">Log in</a></li>
|
||||
{{end}}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue