Updating auth
This commit is contained in:
@@ -202,9 +202,9 @@ impl Condition {
|
||||
Condition::Simple(condition, values) => {
|
||||
// Replace each instance of '?' with increasing numbered binds
|
||||
let mut numbered_condition = String::new();
|
||||
let mut chars = condition.chars().peekable();
|
||||
let chars = condition.chars().peekable();
|
||||
|
||||
while let Some(c) = chars.next() {
|
||||
for c in chars {
|
||||
if c == '?' {
|
||||
// Increment the counter and replace `?` with a numbered bind
|
||||
*counter += 1;
|
||||
|
||||
@@ -40,9 +40,7 @@ impl<'a> QueryBuilder<'a> {
|
||||
|
||||
pub fn order_by(mut self, column: &str, direction: Option<OrderDirection>) -> Self {
|
||||
match direction {
|
||||
Some(order) => self
|
||||
.order_by
|
||||
.push(format!("{} {}", column, order.to_string())),
|
||||
Some(order) => self.order_by.push(format!("{} {}", column, order)),
|
||||
None => self.order_by.push(column.to_string()),
|
||||
}
|
||||
self
|
||||
|
||||
@@ -65,9 +65,8 @@ impl From<sqlx::Error> for Error {
|
||||
sqlx::Error::PoolClosed => Error::new(503, error.to_string()),
|
||||
sqlx::Error::Database(err) => {
|
||||
if let Some(code) = err.code() {
|
||||
match code.trim() {
|
||||
"23505" => return Error::new(409, err.to_string()),
|
||||
_ => (),
|
||||
if code.trim() == "23503" {
|
||||
return Error::new(409, err.to_string());
|
||||
}
|
||||
}
|
||||
Error::new(500, err.to_string())
|
||||
|
||||
@@ -1,2 +1,13 @@
|
||||
pub mod text_utils;
|
||||
|
||||
use rand::RngExt;
|
||||
pub use text_utils::*;
|
||||
|
||||
/// Generate a CSPRNG ID using alphanumeric characters (a-z, A-Z, 0-9)
|
||||
pub fn csprng(take: usize) -> String {
|
||||
rand::rng()
|
||||
.sample_iter(rand::distr::Alphanumeric)
|
||||
.take(take)
|
||||
.map(char::from)
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ pub fn a_or_an(word: &str) -> &'static str {
|
||||
let lowercase_word = word.to_lowercase();
|
||||
|
||||
// Special cases where the article should be "a"
|
||||
let special_cases_a = vec!["one"];
|
||||
let special_cases_a = ["one"];
|
||||
if special_cases_a.contains(&lowercase_word.as_str()) {
|
||||
return "a";
|
||||
}
|
||||
|
||||
// Special cases where the article should be "an"
|
||||
let special_cases_an = vec!["hour"];
|
||||
let special_cases_an = ["hour"];
|
||||
if special_cases_an.contains(&lowercase_word.as_str()) {
|
||||
return "an";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user