Rename route
This commit is contained in:
parent
b5a2f1abcb
commit
8cdb47a139
@ -14,8 +14,8 @@ pub struct Request {
|
|||||||
first_code: String,
|
first_code: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn save_totp_key(user: CurrentUser, form: web::Json<Request>,
|
pub async fn save_totp_factor(user: CurrentUser, form: web::Json<Request>,
|
||||||
users: web::Data<Addr<UsersActor>>) -> impl Responder {
|
users: web::Data<Addr<UsersActor>>) -> impl Responder {
|
||||||
let key = TotpKey::from_encoded_secret(&form.secret);
|
let key = TotpKey::from_encoded_secret(&form.secret);
|
||||||
|
|
||||||
if !key.check_code(&form.first_code).unwrap_or(false) {
|
if !key.check_code(&form.first_code).unwrap_or(false) {
|
||||||
|
@ -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))
|
.route("/settings/two_factors/add_totp", web::get().to(two_factors_controller::add_totp_factor_route))
|
||||||
|
|
||||||
// User API
|
// 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
|
// Admin routes
|
||||||
.route("/admin", web::get()
|
.route("/admin", web::get()
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
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",
|
method: "post",
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
Loading…
Reference in New Issue
Block a user