From 6f0ff853f8225429e78b45e27507d48a3a7f88c8 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Mon, 5 Sep 2022 00:53:35 +0100 Subject: [PATCH] Ensure session data is stored on the session after signup/signin --- src/iam/signin.rs | 5 +++++ src/iam/signup.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/iam/signin.rs b/src/iam/signin.rs index b8ed0c9c..79066559 100644 --- a/src/iam/signin.rs +++ b/src/iam/signin.rs @@ -9,6 +9,7 @@ use chrono::{Duration, Utc}; use jsonwebtoken::{encode, EncodingKey}; use std::sync::Arc; use surrealdb::sql::Object; +use surrealdb::sql::Value; use surrealdb::Auth; use surrealdb::Session; @@ -144,6 +145,10 @@ pub async fn sc( ..Claims::default() }; // 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)); // Create the authentication token match encode(&*HEADER, &val, &key) { diff --git a/src/iam/signup.rs b/src/iam/signup.rs index c32ddf8d..4f3b7ba6 100644 --- a/src/iam/signup.rs +++ b/src/iam/signup.rs @@ -7,6 +7,7 @@ use chrono::{Duration, Utc}; use jsonwebtoken::{encode, EncodingKey}; use std::sync::Arc; use surrealdb::sql::Object; +use surrealdb::sql::Value; use surrealdb::Auth; use surrealdb::Session; @@ -79,6 +80,10 @@ pub async fn sc( ..Claims::default() }; // 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)); // Create the authentication token match encode(&*HEADER, &val, &key) {