\OCPUser

This class provides access to the user management. You can get information about the currently logged in user and the permissions for example

Summary

Methods
Properties
Constants
getUser()
getUsers()
getDisplayName()
getDisplayNames()
isLoggedIn()
userExists()
logout()
checkPassword()
checkAdminUser()
checkLoggedIn()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getUser()

getUser() : string

Get the user id of the user currently logged in.

Returns

string —

uid or false

getUsers()

getUsers(string  $search = '', integer|null  $limit = null, integer|null  $offset = null) : array

Get a list of all users

Parameters

string $search

search pattern

integer|null $limit
integer|null $offset

Returns

array —

an array of all uids

getDisplayName()

getDisplayName(string|null  $user = null) : string

Get the user display name of the user currently logged in.

Parameters

string|null $user

user id or null for current user

Returns

string —

display name

getDisplayNames()

getDisplayNames(string  $search = '', integer|null  $limit = null, integer|null  $offset = null) : array

Get a list of all display names and user ids.

Parameters

string $search

search pattern

integer|null $limit
integer|null $offset

Returns

array —

an array of all display names (value) and the correspondig uids (key)

isLoggedIn()

isLoggedIn() : boolean

Check if the user is logged in

Returns

boolean

userExists()

userExists(string  $uid, string  $excludingBackend = null) : boolean

Check if a user exists

Parameters

string $uid

the username

string $excludingBackend

(default none)

Returns

boolean

logout()

logout() 

Logs the user out including all the session data Logout, destroys session

checkPassword()

checkPassword(string  $uid, string  $password) : string|false

Check if the password is correct

Parameters

string $uid

The username

string $password

The password

Returns

string|false —

username on success, false otherwise

Check if the password is correct without logging in the user

checkAdminUser()

checkAdminUser() 

Check if the user is a admin, redirects to home if not

checkLoggedIn()

checkLoggedIn() 

Check if the user is logged in, redirects to home if not. With redirect URL parameter to the request URI.