summaryrefslogtreecommitdiff
path: root/user.go
diff options
context:
space:
mode:
authorHorus32015-03-19 16:41:39 +0100
committerHorus32015-03-19 16:41:39 +0100
commit77b167ceae8904d827571a0ba7bfa13fac28a40e (patch)
treedc320a8b89911686ebc7af79e2335968aa488e38 /user.go
parente14cf986a916e1a7361b058224ef3badd3aad776 (diff)
downloadfreemail-77b167ceae8904d827571a0ba7bfa13fac28a40e.tar.gz
Regression.
Diffstat (limited to 'user.go')
-rw-r--r--user.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/user.go b/user.go
new file mode 100644
index 0000000..885ec84
--- /dev/null
+++ b/user.go
@@ -0,0 +1,33 @@
+package main
+
+import (
+ "log"
+)
+
+func (vU VirtualUser) HashPassword() string {
+ return Md5Hash(vU.Password)
+}
+
+func (vU VirtualUser) AuthUser() bool {
+ passwd := vU.Password
+ Db.Where("email = ?", vU.Email).Find(&vU)
+ if vU.Password == passwd {
+ return true
+ }
+ return false
+}
+
+func (vU VirtualUser) UpdatePassword(password string) bool {
+ if password == "" {
+ return false
+ }
+ if vU.Password == password {
+ return false
+ }
+ query := Db.Model(&vU).Update("password", password)
+ if query.Error != nil {
+ log.Println(query.Error)
+ return false
+ }
+ return true
+}