Ensure session data is stored on the session after signup/signin
This commit is contained in:
parent
82e347027d
commit
6f0ff853f8
2 changed files with 10 additions and 0 deletions
|
@ -9,6 +9,7 @@ use chrono::{Duration, Utc};
|
||||||
use jsonwebtoken::{encode, EncodingKey};
|
use jsonwebtoken::{encode, EncodingKey};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use surrealdb::sql::Object;
|
use surrealdb::sql::Object;
|
||||||
|
use surrealdb::sql::Value;
|
||||||
use surrealdb::Auth;
|
use surrealdb::Auth;
|
||||||
use surrealdb::Session;
|
use surrealdb::Session;
|
||||||
|
|
||||||
|
@ -144,6 +145,10 @@ pub async fn sc(
|
||||||
..Claims::default()
|
..Claims::default()
|
||||||
};
|
};
|
||||||
// Set the authentication on the sesssion
|
// Set the authentication on the sesssion
|
||||||
|
session.ns = Some(ns.to_owned());
|
||||||
|
session.db = Some(db.to_owned());
|
||||||
|
session.sc = Some(sc.to_owned());
|
||||||
|
session.sd = Some(Value::from(rid));
|
||||||
session.au = Arc::new(Auth::Sc(ns, db, sc));
|
session.au = Arc::new(Auth::Sc(ns, db, sc));
|
||||||
// Create the authentication token
|
// Create the authentication token
|
||||||
match encode(&*HEADER, &val, &key) {
|
match encode(&*HEADER, &val, &key) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ use chrono::{Duration, Utc};
|
||||||
use jsonwebtoken::{encode, EncodingKey};
|
use jsonwebtoken::{encode, EncodingKey};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use surrealdb::sql::Object;
|
use surrealdb::sql::Object;
|
||||||
|
use surrealdb::sql::Value;
|
||||||
use surrealdb::Auth;
|
use surrealdb::Auth;
|
||||||
use surrealdb::Session;
|
use surrealdb::Session;
|
||||||
|
|
||||||
|
@ -79,6 +80,10 @@ pub async fn sc(
|
||||||
..Claims::default()
|
..Claims::default()
|
||||||
};
|
};
|
||||||
// Set the authentication on the sesssion
|
// Set the authentication on the sesssion
|
||||||
|
session.ns = Some(ns.to_owned());
|
||||||
|
session.db = Some(db.to_owned());
|
||||||
|
session.sc = Some(sc.to_owned());
|
||||||
|
session.sd = Some(Value::from(rid));
|
||||||
session.au = Arc::new(Auth::Sc(ns, db, sc));
|
session.au = Arc::new(Auth::Sc(ns, db, sc));
|
||||||
// Create the authentication token
|
// Create the authentication token
|
||||||
match encode(&*HEADER, &val, &key) {
|
match encode(&*HEADER, &val, &key) {
|
||||||
|
|
Loading…
Reference in a new issue