Clean up error handling in crypt
This commit is contained in:
parent
2442a6f2c0
commit
94b83d12aa
7 changed files with 58 additions and 51 deletions
|
@ -35,7 +35,7 @@ fn new_token(user_id: &str, password: &str) -> Option<String> {
|
|||
fn login(token: &str) -> Option<String> {
|
||||
let token = Token::<DefaultHeader, Custom>::parse(token).unwrap();
|
||||
|
||||
if token.verify(b"secret_key") {
|
||||
if token.verify(b"secret_key").unwrap() {
|
||||
Some(token.claims.sub)
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -27,7 +27,7 @@ fn new_token(user_id: &str, password: &str) -> Option<String> {
|
|||
fn login(token: &str) -> Option<String> {
|
||||
let token = Token::<DefaultHeader, Registered>::parse(token).unwrap();
|
||||
|
||||
if token.verify(b"secret_key") {
|
||||
if token.verify(b"secret_key").unwrap() {
|
||||
token.claims.sub
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -40,7 +40,7 @@ fn new_token(user_id: &str, password: &str) -> Option<String> {
|
|||
fn login(token: &str) -> Option<String> {
|
||||
let token = Token::<DefaultHeader, Registered>::parse(token).unwrap();
|
||||
|
||||
if token.verify(load_key("./publicKey.pub").unwrap().as_bytes()) {
|
||||
if token.verify(load_key("./publicKey.pub").unwrap().as_bytes()).unwrap() {
|
||||
token.claims.sub
|
||||
} else {
|
||||
None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue