IAuthHelpers extension
A helper on req.auth, which is typed IAuth?.
It is an extension, not a member of IAuth, so a class that
implements IAuth does not have to add it.
For a guest, req.auth is null, so check req.auth == null.
if (post.userId != req.auth?.id()) abort(403);
- on
Methods
-
id(
) → dynamic -
Available on IAuth, provided by the IAuthHelpers extension
The primary key of the logged-in user, or null for a guest. It calls theid()of the auth class (likeAuthofdox_auth). An auth class with noid()gives null. ANoSuchMethodErrorthrown inside a realid()is also caught and gives null.