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
d535ef8b
Commit
d535ef8b
authored
Jan 12, 2021
by
Robert Czechowski
Browse files
Redirect to profile page on index page (thus also on login) if account is incomplete
parent
8404cbfc
Pipeline
#962
failed with stages
in 2 minutes and 44 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
src/core.rs
View file @
d535ef8b
...
...
@@ -58,6 +58,7 @@ pub enum MedalError {
PasswordHashingError
,
UnmatchedPasswords
,
NotFound
,
AccountIncomplete
,
OauthError
(
String
),
}
...
...
@@ -121,19 +122,23 @@ fn grade_to_string(grade: i32) -> String {
}
pub
fn
index
<
T
:
MedalConnection
>
(
conn
:
&
T
,
session_token
:
Option
<
String
>
,
login_info
:
LoginInfo
)
->
(
String
,
json_val
::
Map
<
String
,
json_val
::
Value
>
)
{
->
MedalValueResult
{
let
mut
data
=
json_val
::
Map
::
new
();
if
let
Some
(
token
)
=
session_token
{
if
let
Some
(
session
)
=
conn
.get_session
(
&
token
)
{
fill_user_data
(
&
session
,
&
mut
data
);
if
session
.logincode
.is_some
()
&&
session
.firstname
.is_none
()
{
return
Err
(
MedalError
::
AccountIncomplete
);
}
}
}
fill_oauth_data
(
login_info
,
&
mut
data
);
data
.insert
(
"parent"
.to_string
(),
to_json
(
&
"base"
));
(
"index"
.to_owned
(),
data
)
Ok
(
(
"index"
.to_owned
(),
data
)
)
}
pub
fn
show_login
<
T
:
MedalConnection
>
(
conn
:
&
T
,
session_token
:
Option
<
String
>
,
login_info
:
LoginInfo
)
...
...
src/webfw_iron.rs
View file @
d535ef8b
...
...
@@ -293,6 +293,11 @@ impl<'c, 'a, 'b> From<AugMedalError<'c, 'a, 'b>> for IronError {
core
::
MedalError
::
NotFound
=>
IronError
{
error
:
Box
::
new
(
SessionError
{
message
:
"Not found"
.to_string
()
}),
response
:
Response
::
with
(
status
::
NotFound
)
},
core
::
MedalError
::
AccountIncomplete
=>
IronError
{
error
:
Box
::
new
(
SessionError
{
message
:
"Account incomplete"
.to_string
()
}),
response
:
Response
::
with
((
status
::
Found
,
Redirect
(
iron
::
Url
::
parse
(
&
format!
(
"{}?status=firstlogin"
,
&
url_for!
(
req
,
"profile"
)))
.unwrap
())))
},
core
::
MedalError
::
OauthError
(
errstr
)
=>
{
IronError
{
error
:
Box
::
new
(
SessionError
{
message
:
format!
(
"Access denied (Error {})"
,
errstr
)
}),
response
:
Response
::
with
(
status
::
Unauthorized
)
}
...
...
@@ -322,7 +327,7 @@ fn greet_personal<C>(req: &mut Request) -> IronResult<Response>
// hier ggf. Daten aus dem Request holen
let
config
=
req
.get
::
<
Read
<
SharedConfiguration
>>
()
.unwrap
();
let
(
template
,
mut
data
)
=
with_conn!
[
core
::
index
,
C
,
req
,
session_token
,
login_info
(
&
config
)];
let
(
template
,
mut
data
)
=
with_conn!
[
core
::
index
,
C
,
req
,
session_token
,
login_info
(
&
config
)]
.aug
(
req
)
?
;
data
.insert
(
"config"
.to_string
(),
to_json
(
&
config
.template_params
));
...
...
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