| Server IP : 157.230.181.24 / Your IP : 216.73.217.11 Web Server : Apache/2.4.58 (Ubuntu) System : Linux conductive 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64 User : ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/vhosts/ceagon/open-oscar-server/state/ |
Upload File : |
package state
import (
"context"
"github.com/google/uuid"
)
// CreateAccountFunc creates a new user account in the database.
//
// Possible errors:
// - ErrAIMHandleInvalidFormat: screen name doesn't start with a letter, ends with a space, or contains invalid
// characters
// - ErrAIMHandleLength: screen name has less than 3 non-space characters or more than 16 characters
// - ErrICQUINInvalidFormat: UIN is not a number or is not in the valid range (10000-2147483646)
// - ErrPasswordInvalid: password length is invalid (AIM: 4-16 chars, ICQ: 6-8 chars)
// - ErrDupUser: a user with the same screen name already exists
// - Other errors from the underlying user store (e.g., database errors)
type CreateAccountFunc func(ctx context.Context, screenName DisplayScreenName, password string) error
// NewAccountCreator returns an account creation function.
func NewAccountCreator(insertUser func(ctx context.Context, u User) error) CreateAccountFunc {
return func(ctx context.Context, screenName DisplayScreenName, password string) error {
if screenName.IsUIN() {
if err := screenName.ValidateUIN(); err != nil {
return err
}
} else {
if err := screenName.ValidateAIMHandle(); err != nil {
return err
}
}
user := User{
AuthKey: uuid.NewString(),
DisplayScreenName: screenName,
IdentScreenName: screenName.IdentScreenName(),
IsICQ: screenName.IsUIN(),
}
if err := user.HashPassword(password); err != nil {
return err
}
if err := insertUser(ctx, user); err != nil {
return err
}
return nil
}
}