func (m *UserMgr) Login(name, passwd string) int { user := m.Users[name] if user == nil { return RS.RS_user_inexistence } if user.PassWord != helper.EncryptPasswd(name, passwd, user.Salt) { return RS.RS_password_error } user.LoginTime = time.Now() return RS.RS_success }
func initAccount() { b, err := ioutil.ReadFile(path + "/conf/init/user.json") if err != nil { panic(err) } user := User{} err = json.Unmarshal(b, &user) if err != nil { panic(err) } user.PassWord = helper.EncryptPasswd(user.UserName, user.PassWord, user.Salt) UMgr.Register(&user) code := UMgr.Update() if code != RS.RS_success { panic("init failed。") } Blogger = UMgr.Get("deepzz") }
func (u *User) ChangePassword(newP string) { u.PassWord = helper.EncryptPasswd(u.UserName, newP, u.Salt) }