diff --git a/db/account.go b/db/account.go index 56e9fc6..5c6bbc7 100644 --- a/db/account.go +++ b/db/account.go @@ -22,7 +22,7 @@ type Account struct { BanReason string } -func NewAccount(db DBQuery, Login, Password string) (*Account, error) { +func (db *DBHandler) NewAccount(Login, Password string) (*Account, error) { hash, err := bcrypt.GenerateFromPassword([]byte(Password), 12) if err != nil { return nil, err @@ -46,7 +46,7 @@ var ( LoginErrorInvalidPassword = fmt.Errorf("Invalid ID && Password combo!") ) -func TryLogin(db DBQuery, Login, Password string) (*Account, error) { +func (db *DBHandler) TryLogin(Login, Password string) (*Account, error) { row, err := db.Query("SELECT * FROM Accounts WHERE Login=?", Login) if err != nil { return nil, err diff --git a/server/login.go b/server/login.go index f10911f..059c767 100644 --- a/server/login.go +++ b/server/login.go @@ -71,10 +71,10 @@ func (server *LoginServer) Login(client *Client, pkt *protocol.Packet) { } // attempt login - account, err := db.TryLogin(db.DefaultDB, loginPkt.SzID, loginPkt.SzPassword) + account, err := db.DefaultDB.TryLogin(loginPkt.SzID, loginPkt.SzPassword) if err == db.LoginErrorInvalidID { // this is the default behavior, auto create the account if the ID isn't in use - account, err = db.NewAccount(db.DefaultDB, loginPkt.SzID, loginPkt.SzPassword) + account, err = db.DefaultDB.NewAccount(loginPkt.SzID, loginPkt.SzPassword) if err != nil { // respond with a dummy login error packet so the client doesn't get softlocked SendError(LOGIN_DATABASE_ERROR)