* Set the user for this scope. * Set to `null` to unset the user.
(user: User | null)
| 266 | * Set to `null` to unset the user. |
| 267 | */ |
| 268 | public setUser(user: User | null): this { |
| 269 | // If null is passed we want to unset everything, but still define keys, |
| 270 | // so that later down in the pipeline any existing values are cleared. |
| 271 | this._user = user || { |
| 272 | email: undefined, |
| 273 | id: undefined, |
| 274 | ip_address: undefined, |
| 275 | username: undefined, |
| 276 | }; |
| 277 | |
| 278 | if (this._session) { |
| 279 | updateSession(this._session, { user }); |
| 280 | } |
| 281 | |
| 282 | this._notifyScopeListeners(); |
| 283 | return this; |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * Get the user from this scope. |
no test coverage detected