NAME

WebService::Bugzilla::User - Bugzilla User object and service

VERSION

version 0.001

SYNOPSIS

use WebService::Bugzilla;

my $bz = WebService::Bugzilla->new(
    base_url => 'https://bugzilla.example.com',
    api_key  => 'your-api-key-here',
);

# Get current logged-in user
my $me = $bz->user->whoami();
say 'Logged in as: ', $me->login_name;

# Get a user by ID or email
my $user = $bz->user->get('user@example.com');
if ($user) {
    say 'Name: ', $user->real_name;
    say 'Email: ', $user->email;
    say 'Enabled: ', $user->is_enabled ? 'yes' : 'no';
}

# Search for users
my $users = $bz->user->search(match => 'admin');
for my $u (@{$users}) {
    say $u->login_name;
}

# Create a new user
my $new = $bz->user->create(
    email     => 'newuser@example.com',
    real_name => 'New User',
);

# Update a user
my $updated = $bz->user->update('user@example.com',
    real_name  => 'Updated Name',
    is_enabled => 1,
);

# Validate credentials
my $valid = $bz->user->valid_login(
    login    => 'user@example.com',
    password => 'secret',
);
say 'Credentials valid: ', $valid ? 'yes' : 'no';

# Login (returns token)
my $result = $bz->user->login(
    login    => 'user@example.com',
    password => 'secret',
);
say 'Token: ', $result->{token};

# Logout
$bz->user->logout();

DESCRIPTION

Provides access to the Bugzilla User API. User objects expose account attributes and provide helpers to create, fetch, search, update, and authenticate users.

Use $bz->user to access the user service from a WebService::Bugzilla instance.

ATTRIBUTES

All attributes are read-only and lazy.

can_login

Boolean. Whether this user account can be used to log in.

creation_time

When the user account was created (ISO 8601 datetime string).

email

The user's email address.

groups

Arrayref of groups this user belongs to.

id

The unique user ID. Inherited from WebService::Bugzilla::Object.

is_blocked

Boolean. Whether this user has been blocked from logging in.

is_enabled

Boolean. Whether this user account is enabled.

login_name

The user's login name (usually an email address).

name

Alias for login_name.

real_name

The user's full name (human-readable name).

saved_searches

Arrayref of saved searches created by this user.

METHODS

BUILDARGS

Moo around modifier. Normalizes incoming construction parameters; accepts login as an alias for login_name.

create

my $user = $bz->user->create(
    email     => 'user@example.com',
    real_name => 'User Name',
);

Create a new user account. Requires email. See POST /rest/user.

Returns a new WebService::Bugzilla::User object.

get

my $user = $bz->user->get('user@example.com');
my $user = $bz->user->get(123);

Fetch a user by ID or email address. See GET /rest/user/{id_or_name}.

Returns a WebService::Bugzilla::User, or undef if not found.

login

my $result = $bz->user->login(
    login    => 'user@example.com',
    password => 'password',
);

Authenticate and obtain a login token. See GET /rest/login.

Returns a hashref with id, token, and other login information.

logout

$bz->user->logout;

Log out the current session. See GET /rest/logout.

my $users = $bz->user->search(match => 'admin');

Search for users. See GET /rest/user.

Returns an arrayref of WebService::Bugzilla::User objects.

update

my $updated = $bz->user->update('user@example.com', real_name => 'New Name');
my $updated = $user->update(real_name => 'New Name');

Update user properties. Can be called as a class method with ID/email or as an instance method. See PUT /rest/user/{id}.

Returns a WebService::Bugzilla::User with updated data.

valid_login

my $valid = $bz->user->valid_login(
    login    => 'user@example.com',
    password => 'password',
);

Validate user credentials without creating a session. See GET /rest/valid_login.

Returns true if the credentials are valid.

whoami

my $me = $bz->user->whoami;

Return information about the currently authenticated user. See GET /rest/whoami.

Returns a WebService::Bugzilla::User for the authenticated user.

SEE ALSO

WebService::Bugzilla - main client

WebService::Bugzilla::UserDetail - lightweight user detail objects

https://bmo.readthedocs.io/en/latest/api/core/v1/user.html - Bugzilla User REST API

AUTHOR

Dean Hamstead <dean@fragfest.com.au>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2026 by Dean Hamstead.

This is free software, licensed under:

The MIT (X11) License