mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-25 08:27:44 +00:00
Move generate_sid to login server
This commit is contained in:
parent
dbade00616
commit
039f4d7f95
2 changed files with 11 additions and 12 deletions
|
@ -5,10 +5,20 @@ use axum::extract::{Query, State};
|
||||||
use axum::response::{Html, Redirect};
|
use axum::response::{Html, Redirect};
|
||||||
use axum::routing::post;
|
use axum::routing::post;
|
||||||
use axum::{Form, Router, routing::get};
|
use axum::{Form, Router, routing::get};
|
||||||
use kawari::generate_sid;
|
use rand::Rng;
|
||||||
|
use rand::distributions::Alphanumeric;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
fn generate_sid() -> String {
|
||||||
|
let random_id: String = rand::thread_rng()
|
||||||
|
.sample_iter(&Alphanumeric)
|
||||||
|
.take(56)
|
||||||
|
.map(char::from)
|
||||||
|
.collect();
|
||||||
|
random_id.to_lowercase()
|
||||||
|
}
|
||||||
|
|
||||||
pub enum LoginError {
|
pub enum LoginError {
|
||||||
WrongUsername,
|
WrongUsername,
|
||||||
WrongPassword,
|
WrongPassword,
|
||||||
|
|
11
src/lib.rs
11
src/lib.rs
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
use common::CustomizeData;
|
use common::CustomizeData;
|
||||||
use minijinja::Environment;
|
use minijinja::Environment;
|
||||||
use rand::Rng;
|
|
||||||
use rand::distributions::Alphanumeric;
|
|
||||||
|
|
||||||
/// The blowfish implementation used for packet encryption.
|
/// The blowfish implementation used for packet encryption.
|
||||||
pub mod blowfish;
|
pub mod blowfish;
|
||||||
|
@ -77,15 +75,6 @@ pub const CHAR_NAME_MAX_LENGTH: usize = 32;
|
||||||
|
|
||||||
pub const CHAR_NAME: &str = "Test User";
|
pub const CHAR_NAME: &str = "Test User";
|
||||||
|
|
||||||
pub fn generate_sid() -> String {
|
|
||||||
let random_id: String = rand::thread_rng()
|
|
||||||
.sample_iter(&Alphanumeric)
|
|
||||||
.take(56)
|
|
||||||
.map(char::from)
|
|
||||||
.collect();
|
|
||||||
random_id.to_lowercase()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn setup_default_environment() -> Environment<'static> {
|
pub fn setup_default_environment() -> Environment<'static> {
|
||||||
let mut env = Environment::new();
|
let mut env = Environment::new();
|
||||||
env.add_template("admin.html", include_str!("../templates/admin.html"))
|
env.add_template("admin.html", include_str!("../templates/admin.html"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue