Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bwinf
medal
Commits
c75f6dfd
Commit
c75f6dfd
authored
Feb 19, 2019
by
Robert Czechowski
Browse files
Remove use of unstable library feature 'try_trait' in order to compile on stable rust again
parent
30b13029
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/functions.rs
View file @
c75f6dfd
...
...
@@ -42,16 +42,9 @@ pub enum MedalError {
CsrfCheckFailed
,
SessionTimeout
,
DatabaseError
,
None
Error
,
PasswordHashing
Error
,
UnmatchedPasswords
,
}
// TODO: Add CsrfCheckFailed, DatabaseError
impl
std
::
convert
::
From
<
std
::
option
::
NoneError
>
for
MedalError
{
fn
from
(
_
:
std
::
option
::
NoneError
)
->
Self
{
MedalError
::
NoneError
}
}
type
MedalValue
=
(
String
,
json_val
::
Map
<
String
,
json_val
::
Value
>
);
type
MedalResult
<
T
>
=
Result
<
T
,
MedalError
>
;
...
...
@@ -509,11 +502,11 @@ pub fn show_profile<T: MedalConnection>(conn: &T, session_token: String, user_id
Ok
((
"profile"
.to_string
(),
data
))
}
fn
hash_password
(
password
:
&
str
,
salt
:
&
str
)
->
Result
<
String
,
Bcrypt
Error
>
{
fn
hash_password
(
password
:
&
str
,
salt
:
&
str
)
->
Result
<
String
,
Medal
Error
>
{
let
password_and_salt
=
[
password
,
salt
]
.concat
()
.to_string
();
match
hash
(
password_and_salt
,
5
)
{
Ok
(
result
)
=>
Ok
(
result
),
Err
(
e
)
=>
Err
(
e
)
Err
(
e
)
=>
Err
(
MedalError
::
PasswordHashingError
)
}
}
...
...
@@ -552,7 +545,7 @@ pub fn edit_profile<T: MedalConnection>(conn: &T, session_token: String, user_id
if
password
!=
""
||
password_repeat
!=
""
{
if
password
==
password_repeat
{
let
salt
:
String
=
thread_rng
()
.sample_iter
(
&
Alphanumeric
)
.take
(
10
)
.collect
();
let
hash
=
hash_password
(
&
password
,
&
salt
)
.ok
()
?
;
let
hash
=
hash_password
(
&
password
,
&
salt
)
?
;
password_salt
=
Some
((
hash
,
salt
));
result
=
ProfileStatus
::
password_changed
;
...
...
src/main.rs
View file @
c75f6dfd
#![feature(try_trait)]
#[macro_use]
extern
crate
iron
;
#[macro_use]
...
...
src/webfw_iron.rs
View file @
c75f6dfd
...
...
@@ -209,8 +209,8 @@ impl<'c, 'a, 'b> From<AugMedalError<'c, 'a, 'b>> for IronError {
functions
::
MedalError
::
DatabaseError
=>
IronError
{
error
:
Box
::
new
(
SessionError
{
message
:
"Database Error"
.to_string
()
}),
response
:
Response
::
with
(
status
::
Forbidden
)
},
functions
::
MedalError
::
None
Error
=>
IronError
{
error
:
Box
::
new
(
SessionError
{
message
:
"
None
Error"
.to_string
()
}),
functions
::
MedalError
::
PasswordHashing
Error
=>
IronError
{
error
:
Box
::
new
(
SessionError
{
message
:
"Error
hashing the passwords
"
.to_string
()
}),
response
:
Response
::
with
(
status
::
Forbidden
)
},
functions
::
MedalError
::
UnmatchedPasswords
=>
IronError
{
error
:
Box
::
new
(
SessionError
{
message
:
"The two passwords did not match."
.to_string
()
}),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment