Overview

Namespaces

  • Charcoal
    • Object
    • User
      • Acl

Classes

  • AbstractUser
  • Authenticator
  • Authorizer
  • AuthToken
  • AuthTokenMetadata
  • GenericUser

Interfaces

  • UserInterface
  • Overview
  • Namespace
  • Class

Class AuthToken

Authorization token; to keep a user logged in

Charcoal\Model\AbstractModel
Extended by Charcoal\User\AuthToken
Namespace: Charcoal\User
Located at Charcoal/User/AuthToken.php
Methods summary
public string
# key( )

Returns

string
public Charcoal\User\AuthToken
# setIdent( string $ident )

Parameters

$ident
The token ident.

Returns

Charcoal\User\AuthToken
Chainable
public string
# ident( )

Returns

string
public Charcoal\User\AuthToken
# setToken( string $token )

Parameters

$token
The token.

Returns

Charcoal\User\AuthToken
Chainable
public string
# token( )

Returns

string
public User
# setUsername( string $username )

Force a lowercase username

Force a lowercase username

Parameters

$username
The username (also the login name).

Returns

User
Chainable

Throws

InvalidArgumentException
If the username is not a string.
public string
# username( )

Returns

string
public Content
# setExpiry( DateTime|string|null $expiry )

Parameters

$expiry
The date/time at object's creation.

Returns

Content
Chainable

Throws

InvalidArgumentException
If the date/time is invalid.
public DateTimeInterface|null
# expiry( )

Returns

DateTimeInterface|null
public Content
# setCreated( DateTime|string|null $created )

Parameters

$created
The date/time at object's creation.

Returns

Content
Chainable

Throws

InvalidArgumentException
If the date/time is invalid.
public DateTime|null
# created( )

Returns

DateTime|null
public Content
# setLastModified( DateTime|string|null $lastModified )

Parameters

$lastModified
The last modified date/time.

Returns

Content
Chainable

Throws

InvalidArgumentException
If the date/time is invalid.
public DateTime
# lastModified( )

Returns

DateTime
public Charcoal\User\AuthToken
# generate( string $username )

Note: the random_bytes() function is new to PHP-7. Available in PHP 5 with compat-random.

Note: the random_bytes() function is new to PHP-7. Available in PHP 5 with compat-random.

Parameters

$username
The username to generate the auth token from.

Returns

Charcoal\User\AuthToken
Chainable
public Charcoal\User\AuthToken
# sendCookie( )

Returns

Charcoal\User\AuthToken
Chainable
public boolean
# preSave( )

StorableTrait > preSave(): Called automatically before saving the object to source.

StorableTrait > preSave(): Called automatically before saving the object to source.

Returns

boolean
public boolean
# preUpdate( array $properties = null )

StorableTrait > preUpdate(): Called automatically before updating the object to source.

StorableTrait > preUpdate(): Called automatically before updating the object to source.

Parameters

$properties
The properties (ident) set for update.

Returns

boolean
public array
# getTokenDataFromCookie( )

Returns

array
`['ident'=>'', 'token'=>'']
public mixed
# getUserId( mixed $ident, string $token )

Parameters

$ident
The auth-token identifier.
$token
The token key to validate against.

Returns

mixed
The user id.
public mixed
# getUsernameFromToken( mixed $ident, string $token )

Parameters

$ident
The auth-token identifier (username).
$token
The token to validate against.

Returns

mixed
The user id. An empty string if no token match.
protected
# panic( )

Something is seriously wrong: a cookie ident was in the database but with a tampered token.

Something is seriously wrong: a cookie ident was in the database but with a tampered token.

protected MetadataInterface
# createMetadata( array $data = null )

DescribableTrait > create_metadata().

DescribableTrait > create_metadata().

Parameters

$data
Optional data to intialize the Metadata object with.

Returns

MetadataInterface
API documentation generated by ApiGen