pub struct Session { /* private fields */ }Expand description
Changes reach the cookie only once the handler’s outcome has committed.
Implementations§
Source§impl Session
impl Session
Sourcepub fn sign_in<A: Area>(
&self,
right: SignInRight,
principal: Id<PrincipalRecord<A>>,
) -> Result<Uuid>
pub fn sign_in<A: Area>( &self, right: SignInRight, principal: Id<PrincipalRecord<A>>, ) -> Result<Uuid>
Issues a fresh cookie, so no session value from before signing in stays valid; whether
the principal may enter the area is the caller’s to check. An action without a
SignInRight cannot sign anyone in:
fn sign_in_anyone<A: Area>(session: &Session, anyone: sofie_db::Id<PrincipalRecord<A>>) {
let _ = session.sign_in::<A>(anyone);
}Sourcepub fn resume<A: Area>(
&self,
right: SignInRight,
session: Uuid,
principal: Id<PrincipalRecord<A>>,
issued_at: Timestamp,
)
pub fn resume<A: Area>( &self, right: SignInRight, session: Uuid, principal: Id<PrincipalRecord<A>>, issued_at: Timestamp, )
Under the session’s own id and first sign-in, so a recent sign-in check does not trust it anew.
pub fn current(&self) -> Option<Uuid>
Sourcepub fn user_agent(&self) -> Option<Cow<'_, str>>
pub fn user_agent(&self) -> Option<Cow<'_, str>>
As the client sent it: untrusted, for showing a session’s device to its owner.
Sourcepub fn origin(&self) -> Option<&str>
pub fn origin(&self) -> Option<&str>
The Origin the browser sent, when it names the host the request was sent to.
Sourcepub fn asked_language(&self) -> Option<&str>
pub fn asked_language(&self) -> Option<&str>
The first language tag of Accept-Language, which browsers list most wanted first;
untrusted, unchecked.
pub fn sign_out(&self)
Sourcepub fn begin_flow(&self) -> Result<String>
pub fn begin_flow(&self) -> Result<String>
Ties a flow through another site, such as an OAuth sign-in, to this browser: the
returned value goes into the flow’s state, and flow reads it back on return.