CHANGE: added encrypted password auth, TODO: add change and add passwd functions
This commit is contained in:
@@ -215,7 +215,7 @@ func (b *Booking) UpdateTime(newTime time.Time){
|
||||
// TODO: add check for time overlap
|
||||
|
||||
var newBooking Booking
|
||||
newBooking.Timestamp = time.Date(b.Timestamp.Year(), b.Timestamp.Month(), b.Timestamp.Day(), hour, minute, 0, 0, time.Local).UTC()
|
||||
newBooking.Timestamp = time.Date(b.Timestamp.Year(), b.Timestamp.Month(), b.Timestamp.Day(), hour, minute, 0, 0, time.Local)
|
||||
if(b.CheckInOut < 3){
|
||||
newBooking.CheckInOut = b.CheckInOut + 2
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"log"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
@@ -94,6 +94,19 @@ func (u *User) GetByPersonalNummer (personalNummer int) (User, error) {
|
||||
}
|
||||
|
||||
func (u *User) Login(password string) bool {
|
||||
userPassword := strings.ToLower(fmt.Sprintf("%s_%s", u.Vorname, u.Name)) //temp password: "max_mustermann"
|
||||
return userPassword == password
|
||||
var loginSuccess bool
|
||||
qStr, err := DB.Prepare((`SELECT (pass_hash = crypt($2, pass_hash)) AS pass_hash FROM user_password WHERE personal_nummer = $1;`))
|
||||
if err != nil {
|
||||
log.Println("Error preparing db statement", err)
|
||||
return false
|
||||
}
|
||||
defer qStr.Close()
|
||||
err = qStr.QueryRow(u.PersonalNummer, password).Scan(&loginSuccess)
|
||||
if err != nil {
|
||||
log.Println("Error queriing db", err)
|
||||
return false
|
||||
}
|
||||
return loginSuccess
|
||||
// userPassword := strings.ToLower(fmt.Sprintf("%s_%s", u.Vorname, u.Name)) //temp password: "max_mustermann"
|
||||
// return userPassword == password
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user