Skip to content

Commit

Permalink
fix: move the email template location and fix the email verification …
Browse files Browse the repository at this point in the history
…code generation

main
  • Loading branch information
sgelias committed Sep 23, 2024
1 parent 87c92fd commit 1936ad0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Warnings:
- You are about to drop the `session_token` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropTable
DROP TABLE "session_token";

-- CreateTable
CREATE TABLE "token" (
"id" SERIAL NOT NULL,
"meta" JSONB NOT NULL,
"expiration" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "token_pkey" PRIMARY KEY ("id")
);
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use mycelium_base::{
entities::CreateResponseKind,
utils::errors::{use_case_err, MappedErrors},
};
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use rand::{thread_rng, Rng};
use tera::Context;
use uuid::Uuid;

Expand All @@ -38,16 +38,13 @@ pub(super) async fn register_token_and_notify_user(
//
// ? -----------------------------------------------------------------------

let random_number: String = thread_rng()
.sample_iter(&Alphanumeric)
.take(6)
.map(char::from)
.collect();
let random_number = thread_rng().gen_range(0..999_999);
let fixed_size_string = format!("{:06}", random_number);

let meta = EmailConfirmationTokenMeta::new(
user_id,
email.to_owned(),
random_number,
fixed_size_string,
);

let token = match token_registration_repo
Expand Down
34 changes: 18 additions & 16 deletions ports/api/src/endpoints/standard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,12 @@ mod user_account_manager;
use super::shared::UrlGroup;
use crate::endpoints::standard::shared::build_actor_context;

use actix_web::{get, web, HttpResponse, Responder};
use guest_manager::{
guest_endpoints as guest_manager_guest_endpoints,
guest_role_endpoints as guest_manager_guest_role_endpoints,
role_endpoints as guest_manager_role_endpoints,
};
use no_role::{
account_endpoints as no_role_account_endpoints,
auxiliary_endpoints as no_role_auxiliary_endpoints,
guest_endpoints as no_role_guest_endpoints,
profile_endpoints as no_role_profile_endpoints,
user_endpoints as no_role_user_endpoints,
};
use subscription_account_manager::account_endpoints as subscription_account_manager_account_endpoints;
use system_manager::{
error_code_endpoints as system_manager_error_code_endpoints,
webhook_endpoints as system_manager_webhook_endpoints,
};
use user_account_manager::account_endpoints as user_account_manager_account_endpoints;

use actix_web::{get, web, HttpResponse, Responder};
use myc_core::{
domain::{
actors::DefaultActor,
Expand All @@ -39,7 +25,7 @@ use myc_core::{
guest::{GuestRole, GuestUser},
profile::{LicensedResources, Profile},
role::Role,
user::User,
user::{PasswordHash, Provider, User},
webhook::{AccountPropagationWebHookResponse, HookTarget, WebHook},
},
},
Expand All @@ -50,6 +36,19 @@ use myc_core::{
};
use myc_http_tools::utils::JsonError;
use mycelium_base::dtos::{Children, PaginatedRecord, Parent};
use no_role::{
account_endpoints as no_role_account_endpoints,
auxiliary_endpoints as no_role_auxiliary_endpoints,
guest_endpoints as no_role_guest_endpoints,
profile_endpoints as no_role_profile_endpoints,
user_endpoints as no_role_user_endpoints,
};
use subscription_account_manager::account_endpoints as subscription_account_manager_account_endpoints;
use system_manager::{
error_code_endpoints as system_manager_error_code_endpoints,
webhook_endpoints as system_manager_webhook_endpoints,
};
use user_account_manager::account_endpoints as user_account_manager_account_endpoints;
use utoipa::OpenApi;

#[get("/")]
Expand Down Expand Up @@ -257,7 +256,9 @@ pub(crate) fn configure(config: &mut web::ServiceConfig) {
ActionType,
JsonError,
LicensedResources,
PasswordHash,
Profile,
Provider,
Permissions,
VerboseStatus,
User,
Expand All @@ -277,6 +278,7 @@ pub(crate) fn configure(config: &mut web::ServiceConfig) {
system_manager_webhook_endpoints::UpdateWebHookBody,
guest_manager_guest_role_endpoints::UpdateGuestRolePermissionsBody,
no_role_user_endpoints::CheckEmailStatusBody,
no_role_user_endpoints::CreateDefaultUserBody,
),
),
tags(
Expand Down
File renamed without changes.

0 comments on commit 1936ad0

Please sign in to comment.