From c6117f1c2fba35aee7dc6bc68da6d118b31cae11 Mon Sep 17 00:00:00 2001 From: Las Zenow Date: Tue, 3 Sep 2013 14:15:30 +0200 Subject: [PATCH] Add user creation --- database.go | 5 +++++ templates/header.html | 1 + templates/login.html | 51 +++++++++++++++++++++++++++++++++++++++++++ trantor.go | 1 + user.go | 18 +++++++++++++++ 5 files changed, 76 insertions(+) diff --git a/database.go b/database.go index 662860c..ce880e3 100644 --- a/database.go +++ b/database.go @@ -89,6 +89,11 @@ func (d *DB) UserValid(user string, pass string) bool { return n != 0 } +func (d *DB) AddUser(user string, pass string) error { + hash := md5Pass(pass) + return d.user.Insert(bson.M{"user": user, "pass": hash, "role": ""}) +} + func (d *DB) UserRole(user string) string { type result struct { Role string diff --git a/templates/header.html b/templates/header.html index 78a68d5..1fbe133 100644 --- a/templates/header.html +++ b/templates/header.html @@ -16,6 +16,7 @@