Login endpoint #20
@@ -50,9 +50,12 @@ mod token_stuff {
|
||||
|
||||
pub const TOKENTYPE: &str = "JWT";
|
||||
pub const TESTKEY: &str = "dfsdferferf";
|
||||
pub const KEY_ENV: &str = "SECRET_KEY";
|
||||
|
||||
fn get_key() -> Result<String, dotenvy::Error> {
|
||||
Ok(String::from(TESTKEY))
|
||||
pub fn get_key() -> Result<String, dotenvy::Error> {
|
||||
dotenvy::dotenv().ok();
|
||||
let key = std::env::var(KEY_ENV).expect("SECRET_KEY_NOT_FOUND");
|
||||
Ok(key)
|
||||
}
|
||||
|
||||
pub fn create_token(provided_key: &String) -> Result<String, josekit::JoseError> {
|
||||
@@ -91,7 +94,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_tokenize() {
|
||||
let special_key = String::from("mysecret-dsfsdfsdfsdfsdgfsdgsdgsdfg");
|
||||
let special_key = token_stuff::get_key().unwrap();
|
||||
match token_stuff::create_token(&special_key) {
|
||||
Ok(token) => {
|
||||
let result = token_stuff::verify_token(&special_key, &token);
|
||||
|
Reference in New Issue
Block a user