Skip to content

Commit

Permalink
fix verification
Browse files Browse the repository at this point in the history
  • Loading branch information
m1guelpf committed Nov 17, 2023
1 parent 2dbcfc9 commit d4365af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/bot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type HandlerResult = Result<(), HandlerError>;
pub type JoinRequests = Arc<DashMap<(ChatId, UserId), JoinRequest>>;
type HandlerError = Box<dyn std::error::Error + Send + Sync>;

#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct JoinRequest {
pub is_verified: bool,
pub msg_id: Option<MessageId>,
Expand Down
10 changes: 7 additions & 3 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub async fn start(bot: Bot, config: AppConfig, bot_data: User, join_requests: J
}),
)
.route(
"/verify/:chat_id/:msg_id",
"/verify/:chat_id/:user_id",
get(verify_page).post(verify_api),
)
.layer(Extension(bot))
Expand Down Expand Up @@ -68,6 +68,7 @@ async fn verify_page(
<script>
IDKit.init({{
autoClose: true,
signal: '{msg_id}',
app_id: '{app_id}',
action: '{chat_id}',
Expand All @@ -76,13 +77,16 @@ async fn verify_page(
}})
window.addEventListener('load', async () => {{
await fetch('/verify/{chat_id}/{msg_id}', {{
const res = await fetch('/verify/{chat_id}/{user_id}', {{
method: 'POST',
body: JSON.stringify(await IDKit.open()),
headers: {{ 'Content-Type': 'application/json' }},
}})
alert('Successfully verified!')
if (res.ok) alert('Successfully verified!')
else alert('Something went wrong, please try again later.')
window.close()
}})
</script>
</body>
Expand Down

0 comments on commit d4365af

Please sign in to comment.