mirror of
https://github.com/actix/actix-extras.git
synced 2025-03-15 18:03:06 +01:00
update based on feedback, this is in a broken state
This commit is contained in:
parent
b313f40ef0
commit
091a49af4c
@ -79,7 +79,7 @@ impl Default for SessionStatus {
|
||||
struct SessionInner {
|
||||
state: HashMap<String, String>,
|
||||
status: SessionStatus,
|
||||
session_key: SessionKey,
|
||||
session_key: Option<SessionKey>,
|
||||
}
|
||||
|
||||
impl Session {
|
||||
@ -108,8 +108,10 @@ impl Session {
|
||||
///
|
||||
/// Retrieve the overall session key
|
||||
pub fn get_session_key(&self) -> secrecy::Secret<SessionKey> {
|
||||
let key = todo!("populate key somehow");
|
||||
secrecy::Secret::new(key)
|
||||
todo!("either grab the key or figure out how to populate InnerSession session_key field");
|
||||
// let key = Session::set_session(&mut self.0., self.0);
|
||||
let key = self.0.borrow().session_key.clone(); //
|
||||
secrecy::Secret::new(key.unwrap())
|
||||
}
|
||||
/// Get all raw key-value data from the session.
|
||||
///
|
||||
|
@ -1,6 +1,7 @@
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use derive_more::{Display, From};
|
||||
use secrecy::Secret;
|
||||
|
||||
/// A session key, the string stored in a client-side cookie to associate a user with its session
|
||||
/// state on the backend.
|
||||
@ -17,8 +18,8 @@ use derive_more::{Display, From};
|
||||
/// let session_key: Result<SessionKey, _> = key.try_into();
|
||||
/// assert!(session_key.is_err());
|
||||
/// ```
|
||||
#[derive(Debug, PartialEq, Eq, Default, Clone)]
|
||||
pub struct SessionKey(pub String);
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SessionKey(secrecy::Secret<String>);
|
||||
|
||||
impl TryFrom<String> for SessionKey {
|
||||
type Error = InvalidSessionKeyError;
|
||||
@ -30,13 +31,13 @@ impl TryFrom<String> for SessionKey {
|
||||
)
|
||||
.into());
|
||||
}
|
||||
|
||||
Ok(SessionKey(val))
|
||||
let val_secret = Secret::new(val);
|
||||
Ok(SessionKey(val_secret))
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<str> for SessionKey {
|
||||
fn as_ref(&self) -> &str {
|
||||
impl AsRef<secrecy::Secret<String>> for SessionKey {
|
||||
fn as_ref(&self) -> &secrecy::Secret<String> {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user