Two factor authentication : TOTP #5

Merged
pierre merged 22 commits from twofactors into master 2022-04-20 07:40:51 +00:00
3 changed files with 4 additions and 4 deletions
Showing only changes of commit 8cdb47a139 - Show all commits

View File

@ -14,8 +14,8 @@ pub struct Request {
first_code: String,
}
pub async fn save_totp_key(user: CurrentUser, form: web::Json<Request>,
users: web::Data<Addr<UsersActor>>) -> impl Responder {
pub async fn save_totp_factor(user: CurrentUser, form: web::Json<Request>,
users: web::Data<Addr<UsersActor>>) -> impl Responder {
let key = TotpKey::from_encoded_secret(&form.secret);
if !key.check_code(&form.first_code).unwrap_or(false) {

View File

@ -122,7 +122,7 @@ async fn main() -> std::io::Result<()> {
.route("/settings/two_factors/add_totp", web::get().to(two_factors_controller::add_totp_factor_route))
// User API
.route("/settings/api/two_factors/save_totp_key", web::post().to(two_factors_api::save_totp_key))
.route("/settings/api/two_factors/save_totp_factor", web::post().to(two_factors_api::save_totp_factor))
// Admin routes
.route("/admin", web::get()

View File

@ -75,7 +75,7 @@
return;
try {
const res = await fetch("/settings/api/two_factors/save_totp_key", {
const res = await fetch("/settings/api/two_factors/save_totp_factor", {
method: "post",
headers: {
'Content-Type': 'application/json',