Use different contexts for verification and confirmation.

This commit is contained in:
Justus Winter 2019-03-11 16:34:18 +01:00
parent e908df4b9f
commit 7d115714a2
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386
1 changed files with 16 additions and 9 deletions

View File

@ -9,11 +9,19 @@ use serde::Serialize;
use database::types::Email;
use Result;
#[derive(Serialize, Clone)]
pub struct Context {
pub token: String,
pub userid: Option<String>,
pub domain: String,
mod context {
#[derive(Serialize, Clone)]
pub struct Verification {
pub token: String,
pub userid: String,
pub domain: String,
}
#[derive(Serialize, Clone)]
pub struct Deletion {
pub token: String,
pub domain: String,
}
}
pub struct Service {
@ -50,9 +58,9 @@ impl Service {
pub fn send_verification(&self, userid: &Email, token: &str, domain: &str)
-> Result<()> {
let ctx = Context {
let ctx = context::Verification {
token: token.to_string(),
userid: Some(userid.to_string()),
userid: userid.to_string(),
domain: domain.to_string(),
};
@ -67,9 +75,8 @@ impl Service {
pub fn send_confirmation(&self, userids: &[Email], token: &str,
domain: &str)
-> Result<()> {
let ctx = Context {
let ctx = context::Deletion {
token: token.to_string(),
userid: None,
domain: domain.to_string(),
};