ezidam: oauth: redirect: redirect automatically to home page
This commit is contained in:
parent
827bba041a
commit
e9200f8682
3 changed files with 14 additions and 0 deletions
|
|
@ -32,5 +32,6 @@ pub mod content {
|
||||||
pub user_id: String,
|
pub user_id: String,
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub username: String,
|
pub username: String,
|
||||||
|
pub home_page: String,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::routes::prelude::*;
|
use crate::routes::prelude::*;
|
||||||
use authorization_codes::AuthorizationCode;
|
use authorization_codes::AuthorizationCode;
|
||||||
use rocket::{get, UriDisplayQuery};
|
use rocket::{get, UriDisplayQuery};
|
||||||
|
use settings::Settings;
|
||||||
use users::User;
|
use users::User;
|
||||||
|
|
||||||
#[derive(Debug, FromForm, UriDisplayQuery)]
|
#[derive(Debug, FromForm, UriDisplayQuery)]
|
||||||
|
|
@ -42,6 +43,13 @@ pub async fn redirect_page(
|
||||||
// Mark code as used
|
// Mark code as used
|
||||||
code.use_code(&mut transaction).await?;
|
code.use_code(&mut transaction).await?;
|
||||||
|
|
||||||
|
// Get base url
|
||||||
|
let settings = Settings::get(&mut transaction).await?;
|
||||||
|
let home_page = settings
|
||||||
|
.url()
|
||||||
|
.map(String::from)
|
||||||
|
.ok_or_else(|| Error::bad_request("Server url is not set"))?;
|
||||||
|
|
||||||
transaction.commit().await?;
|
transaction.commit().await?;
|
||||||
|
|
||||||
// HTTP Response
|
// HTTP Response
|
||||||
|
|
@ -49,5 +57,6 @@ pub async fn redirect_page(
|
||||||
user_id: user.id().to_string(),
|
user_id: user.id().to_string(),
|
||||||
name: user.name().map(String::from),
|
name: user.name().map(String::from),
|
||||||
username: user.username().to_string(),
|
username: user.username().to_string(),
|
||||||
|
home_page,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="text-center text-muted mt-3">
|
||||||
|
<a href="{{ home_page }}" tabindex="-1">Click here if you are not redirected</a>
|
||||||
|
<meta http-equiv="refresh" content="1; url={{ home_page }}">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% include "shell/footer" %}
|
{% include "shell/footer" %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue