summaryrefslogtreecommitdiff
path: root/src/token.rs
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2016-12-18 23:24:04 +0100
committerYves Fischer <yvesf-git@xapek.org>2016-12-18 23:24:04 +0100
commit02932ee8b40669b3cbaecda202cf2c949d370904 (patch)
treeb8dae6f7f8efde35d76530268fd486641bd4c31a /src/token.rs
parent8ceac0236c555979a9172c69c1a9e895d7487d6f (diff)
downloadauth-xmppmessage-02932ee8b40669b3cbaecda202cf2c949d370904.tar.gz
auth-xmppmessage-02932ee8b40669b3cbaecda202cf2c949d370904.zip
Print the original URL with username/password in the messageHEADmaster
Diffstat (limited to 'src/token.rs')
-rw-r--r--src/token.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/token.rs b/src/token.rs
index 2a2e446..ff5a396 100644
--- a/src/token.rs
+++ b/src/token.rs
@@ -24,8 +24,9 @@ impl TokenGenerator {
/// Return (from, to, token)
pub fn generate_token(&self, username: &str, at_time: i64) -> (i64, i64, String) {
let timeslot = at_time - (at_time % self.valid_duration_secs);
- let input: String = format!("{}{}", username, timeslot);
- return (timeslot, timeslot + self.valid_duration_secs, self.make_hash_token(&input.as_bytes()))
+ let input = format!("{}{}", username, timeslot);
+ let token = self.make_hash_token(&input.as_bytes());
+ return (timeslot, timeslot + self.valid_duration_secs, token)
}
#[inline(always)]
@@ -64,7 +65,7 @@ mod tests {
fn test_generate_token() {
use time;
let tg = TokenGenerator::new(time::Duration::hours(2).num_seconds(),
- vec!(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16));
+ vec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16));
let (valid_from, valid_until, result) = tg.generate_token("a", 99999999);
assert_eq!( valid_from, 99993600);
assert_eq!( valid_until, 100000800);