Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
STS
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coscine
backend
apis
STS
Merge requests
!3
Topic/231 or ci d integration
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Topic/231 or ci d integration
Topic/231-ORCiDIntegration
into
Product/224-loginPage
Overview
0
Commits
5
Pipelines
1
Changes
13
Merged
Topic/231 or ci d integration
Benedikt Heinrichs
requested to merge
Topic/231-ORCiDIntegration
into
Product/224-loginPage
Aug 30, 2019
Overview
0
Commits
5
Pipelines
1
Changes
13
0
0
Merge request reports
Compare
Product/224-loginPage
Product/224-loginPage (base)
and
latest version
latest version
d0aca1dc
5 commits,
Aug 30, 2019
13 files
+
346
−
32
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
13
src/STS/Controllers/AccountController.cs
+
7
−
25
View file @ d0aca1dc
Edit in single-file editor
Open in Web IDE
Show full file
@@ -13,6 +13,8 @@ using Microsoft.AspNetCore.Authentication.Cookies;
using
Microsoft.AspNetCore.Authentication
;
using
System.Threading.Tasks
;
using
System
;
using
Coscine.STS.Utils
;
using
System.Net
;
namespace
Coscine.STS.Controllers
{
@@ -21,34 +23,13 @@ namespace Coscine.STS.Controllers
[
Route
(
"[controller]/login"
)]
public
ActionResult
Login
(
string
returnUrl
)
{
ViewBag
.
ReturnUrl
=
ExtendReturnUrl
(
returnUrl
);
ViewBag
.
ReturnUrl
=
UrlGenerator
.
ExtendReturnUrl
(
returnUrl
,
Request
);
ViewBag
.
ORCiDUrl
=
ORCiDHandler
.
GetORCiDOAuthUrl
()
+
UrlGenerator
.
ORCiDRedirectUrl
();
System
.
Text
.
ASCIIEncoding
enc
=
new
System
.
Text
.
ASCIIEncoding
();
ViewBag
.
AppJs
=
enc
.
GetString
(
Program
.
Configuration
.
GetAndWait
(
"coscine/apps/login/appjs"
));
return
View
();
}
private
string
ExtendReturnUrl
(
string
returnUrl
)
{
string
retString
=
returnUrl
;
if
(!
retString
.
Contains
(
"?"
))
{
retString
+=
"?wa=wsignin1.0"
;
}
if
(
Request
.
Query
[
"wtrealm"
].
Count
!=
0
&&
!
retString
.
Contains
(
"wtrealm="
))
{
retString
+=
"&wtrealm="
+
Request
.
Query
[
"wtrealm"
][
0
];
}
if
(
Request
.
Query
[
"wctx"
].
Count
!=
0
&&
!
retString
.
Contains
(
"wctx="
))
{
retString
+=
"&wctx="
+
Request
.
Query
[
"wctx"
][
0
];
}
if
(
Request
.
Query
[
"wreply"
].
Count
!=
0
&&
!
retString
.
Contains
(
"wreply="
))
{
retString
+=
"&wreply="
+
Request
.
Query
[
"wreply"
][
0
];
}
return
retString
;
}
[
HttpPost
(
"[controller]/login"
)]
public
async
Task
<
ActionResult
>
Login
(
LoginModel
model
,
string
returnUrl
)
{
@@ -60,10 +41,11 @@ namespace Coscine.STS.Controllers
await
HttpContext
.
SignInAsync
(
CookieAuthenticationDefaults
.
AuthenticationScheme
,
new
ClaimsPrincipal
(
identity
));
return
Redirect
(
ExtendReturnUrl
(
returnUrl
));
return
Redirect
(
UrlGenerator
.
ExtendReturnUrl
(
returnUrl
,
Request
));
}
ViewBag
.
ReturnUrl
=
ExtendReturnUrl
(
returnUrl
);
ViewBag
.
ReturnUrl
=
UrlGenerator
.
ExtendReturnUrl
(
returnUrl
,
Request
);
ViewBag
.
ORCiDUrl
=
ORCiDHandler
.
GetORCiDOAuthUrl
()
+
UrlGenerator
.
ORCiDRedirectUrl
();
ModelState
.
AddModelError
(
""
,
"The userid provided is incorrect."
);
return
View
(
model
);
}
Loading