// Authorize a user to access the API. func Authorize(user, password string) (id string, err error) { var result *db.Result if result, err = db.Query(usersql.Authorize, user, user, password); nil != err { return } defer result.Free() if !result.ScanNextRow(&id) { err = fmt.Errorf("User %s not found", user) } return }
// Add a new user. func Add(user, password string) (err error) { var result *db.Result if result, err = db.Query(usersql.Add, user, password); nil != err { return } defer result.Free() var id string if !result.ScanNextRow(&id) || db.IsNull(id) { err = fmt.Errorf("Failed to insert user %s", user) } return }