[Draft] Implement Reviewer Notice Link using Login Redirect #40
6 changed files with 21 additions and 8 deletions
have reviewer notice link redirect via the login page
# Conflicts: # Changelog.md # src/route/job_offer/create.rs
commit
fd42f77cff
|
|
@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- startup errors are more descriptive
|
||||
- the confirmation link now works after confirmation so that submissions can be deleted early by the submitter
|
||||
- this changes the on-disk format slightly as the token now has a different scope and was moved accordingly
|
||||
- reviewe notice link is now indirect via the login page
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::job_offers::error::EmailError;
|
||||
use crate::route::RETURN_TO;
|
||||
use crate::server_config::EmailConfig;
|
||||
use crate::template;
|
||||
use handlebars::Handlebars;
|
||||
|
|
@ -68,13 +69,18 @@ pub(crate) async fn send_confirmation_email(
|
|||
pub(crate) async fn send_reviewer_notice(
|
||||
hb: &Handlebars<'_>,
|
||||
email_config: &EmailConfig,
|
||||
url: Url,
|
||||
highlight_url: Url,
|
||||
mut login_url: Url,
|
||||
) {
|
||||
// successfully send a confirmation e-mail now send a notice to our-self
|
||||
|
||||
login_url
|
||||
.query_pairs_mut()
|
||||
.append_pair(RETURN_TO, highlight_url.as_str());
|
||||
|
||||
let body = match hb.render(
|
||||
template::EMAIL_REVIEWER_NOTICE,
|
||||
&json!({ "highlight_link": url }),
|
||||
&json!({ "highlight_link": login_url }),
|
||||
) {
|
||||
Ok(body) => body,
|
||||
Err(err) => {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ pub(crate) mod form_constants;
|
|||
mod job_offer;
|
||||
mod license;
|
||||
|
||||
pub(crate) use auth::{LOGIN_ROUTE, LOGOUT_ROUTE};
|
||||
pub(crate) use auth::{LOGIN_ROUTE, LOGOUT_ROUTE, RETURN_TO};
|
||||
pub(crate) use job_offer::{
|
||||
confirmation::JOBOFFER_CONFIRM_ROUTE,
|
||||
create::JOBOFFER_CREATION_ROUTE,
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ pub(crate) fn configure(config: &mut ServiceConfig) {
|
|||
}
|
||||
|
||||
pub(crate) const LOGIN_ROUTE: &str = "login";
|
||||
pub(crate) const RETURN_TO: &str = "return_to";
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub(crate) struct LoginQuery {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ use multipart_helper::MultipartFieldError;
|
|||
use serde_json::json;
|
||||
use url::Url;
|
||||
|
||||
use super::auth::RETURN_TO;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[error("Some error occurred while attempting to display an error page")]
|
||||
pub struct ErrorHandlerResponseError;
|
||||
|
|
@ -226,7 +228,7 @@ fn login_url_with_return(req: &HttpRequest, return_to: &str) -> Result<Url, UrlG
|
|||
|
||||
login_url
|
||||
.query_pairs_mut()
|
||||
.append_pair("return_to", return_to);
|
||||
.append_pair(RETURN_TO, return_to);
|
||||
|
||||
Ok(login_url)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ use crate::job_offers::{
|
|||
use crate::route::form_constants::{self, UploadLimits};
|
||||
use crate::route::job_offer::confirmation::JOBOFFER_CONFIRM_ROUTE;
|
||||
use crate::route::job_offer::error::{FormProcessingError, SubmissionResponseError};
|
||||
use crate::route::HTML_CONTENT;
|
||||
use crate::route::{HTML_CONTENT, LOGIN_ROUTE};
|
||||
use crate::server_config::ServerConfig;
|
||||
use crate::util::{parse_date, parse_datetime, process_links, process_new_attachments};
|
||||
use crate::{email, template};
|
||||
|
|
@ -248,9 +248,12 @@ pub(crate) async fn create_job_offer<'data, 'config>(
|
|||
|
||||
if let Some(email_config) = &config.config.email {
|
||||
if !is_pre_approved {
|
||||
match created_offer.highlight_link(req) {
|
||||
Ok(highlight_url) => {
|
||||
email::send_reviewer_notice(hb, email_config, highlight_url).await;
|
||||
match created_offer
|
||||
.highlight_link(req)
|
||||
.and_then(|highlight| Ok((highlight, req.url_for_static(LOGIN_ROUTE)?)))
|
||||
{
|
||||
Ok((highlight_url, login_url)) => {
|
||||
email::send_reviewer_notice(hb, &email_config, highlight_url, login_url).await;
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Failed to generate highlight link: {}", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue