KScript docs
EN

users fields and methods

A field is a plain fact about the value, read with a dot and no brackets: $value.name. A method takes arguments or does work, and is called with ->: $value->name(arguments), or with the value piped in: $value |> name(arguments).

From KScript.Auth

These need <import package="KScript.Auth" />import KScript.Auth. See KScript.Auth.

#users->all() → list KScript.Auth

Every user, oldest first.
Example
<for each="u" in="@users()->all()"><echo>{ $u.email }</echo></for>
for u in @users()->all() {
  echo $u.email
}

#users->count() → number KScript.Auth

How many users there are.
Example
<echo>{ @users()->count() }</echo>
echo @users()->count()

#users->delete(id) → bool KScript.Auth

Deletes a user, with their sessions and tokens. True if there was one.
Example
<do>@users()->delete($user.id)</do>
@users()->delete($user.id)

#users->find(id) → map KScript.Auth

The user with this id, or null.
Example
<let name="user" value="@users()->find($id)" />
$user = @users()->find($id)

#users->find_email(email) → map KScript.Auth

The user with this email (case doesn't matter), or null.
Example
<let name="user" value="@users()->find_email('joan@example.com')" />
$user = @users()->find_email('joan@example.com')

#users->set_password(id, password) → map KScript.Auth

Gives a user a new password, checked by the password type, and returns the user.

Arguments can be named: ->set_password(…, password: …).

Example
<do>@users()->set_password($user.id, $form.password)</do>
@users()->set_password($user.id, $form.password)

#users->update(id, fields...: User) → map KScript.Auth

Changes a user's fields (null removes one) and returns the user. A new email is checked like @register()'s.
ParameterTakes
id requiredany value
fieldsUser, any number of them

Arguments can be named: ->update(…, fields: …).

Example
<do>@users()->update($user.id, name: 'Joan Clarke')</do>
@users()->update($user.id, name: 'Joan Clarke')

#users->verify(email, password) → map KScript.Auth

The user with this email and password, or null. Unlike @attempt(), it doesn't sign them in or count failures.

Arguments can be named: ->verify(…, password: …).

Example
<let name="user" value="@users()->verify($email, $password)" />
$user = @users()->verify($email, $password)

Methods from any