Browse Source

Merge branch 'computing' into V20220125.patch

tags/v1.22.1.4^2
wangjr 3 years ago
parent
commit
a377b02058
6 changed files with 47 additions and 14 deletions
  1. +5
    -0
      modules/context/auth.go
  2. +17
    -1
      routers/user/auth.go
  3. +17
    -5
      templates/base/head_navbar.tmpl
  4. +1
    -1
      templates/org/course_list.tmpl
  5. +2
    -6
      templates/org/home_courses.tmpl
  6. +5
    -1
      templates/user/auth/signin_inner.tmpl

+ 5
- 0
modules/context/auth.go View File

@@ -64,6 +64,11 @@ func Toggle(options *ToggleOptions) macaron.Handler {
ctx.Redirect(setting.AppSubURL + "/")
return
}

if ctx.QueryBool("course") {
ctx.Redirect(setting.AppSubURL + "/" + setting.Course.OrgName)
return
}
}

// Redirect to dashboard if user tries to visit any non-login page.


+ 17
- 1
routers/user/auth.go View File

@@ -116,8 +116,16 @@ func checkAutoLogin(ctx *context.Context) bool {
}

if isSucceed {

isCourse := ctx.QueryBool("course")
ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL, "", setting.SessionConfig.Secure, true)
ctx.RedirectToFirst(redirectTo, setting.AppSubURL+string(setting.LandingPageURL))
if redirectTo == "" && isCourse {
redirectToCourse := setting.AppSubURL + "/" + setting.Course.OrgName
ctx.RedirectToFirst(redirectToCourse)
} else {
ctx.RedirectToFirst(redirectTo, setting.AppSubURL+string(setting.LandingPageURL))

}
return true
}

@@ -143,6 +151,7 @@ func SignIn(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("sign_in")
ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login"
ctx.Data["PageIsSignIn"] = true
ctx.Data["IsCourse"] = ctx.QueryBool("course")
ctx.Data["PageIsLogin"] = true
ctx.Data["EnableSSPI"] = models.IsSSPIEnabled()
ctx.Data["EnableCloudBrain"] = true
@@ -182,6 +191,7 @@ func SignInPost(ctx *context.Context, form auth.SignInForm) {
ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login"
ctx.Data["PageIsSignIn"] = true
ctx.Data["PageIsLogin"] = true
ctx.Data["IsCourse"] = ctx.QueryBool("course")
ctx.Data["EnableSSPI"] = models.IsSSPIEnabled()

if ctx.HasError() {
@@ -565,6 +575,12 @@ func handleSignInFull(ctx *context.Context, u *models.User, remember bool, obeyR
return setting.AppSubURL + "/dashboard"
}

isCourse := ctx.QueryBool("course")
if isCourse {
redirectToCourse := setting.AppSubURL + "/" + setting.Course.OrgName
ctx.RedirectToFirst(redirectToCourse)
return redirectToCourse
}
if redirectTo := ctx.GetCookie("redirect_to"); len(redirectTo) > 0 && !util.IsExternalURL(redirectTo) {
ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL, "", setting.SessionConfig.Secure, true)
if obeyRedirect {


+ 17
- 5
templates/base/head_navbar.tmpl View File

@@ -211,13 +211,25 @@
</div>
</form>
{{if .ShowRegistrationButton}}
<a class="item{{if .PageIsSignUp}} active{{end}}" href="{{AppSubUrl}}/user/sign_up">
{{svg "octicon-person" 16}} {{.i18n.Tr "register"}}
{{if .IsCourse}}
<a class="item{{if .PageIsSignUp}} active{{end}}" href="https://git.openi.org.cn/user/sign_up" target="_blank">
{{svg "octicon-person" 16}} {{.i18n.Tr "register"}}
</a>
{{else}}
<a class="item{{if .PageIsSignUp}} active{{end}}" href="{{AppSubUrl}}/user/sign_up">
{{svg "octicon-person" 16}} {{.i18n.Tr "register"}}
</a>
{{end}}
{{end}}
{{if .IsCourse}}
<a class="item{{if .PageIsSignIn}} active{{end}}" rel="nofollow" href="https://git.openi.org.cn/user/login?course=true" target="_blank">
{{svg "octicon-sign-in" 16}} {{.i18n.Tr "sign_in"}}
</a>
{{else}}
<a class="item{{if .PageIsSignIn}} active{{end}}" rel="nofollow" href="{{AppSubUrl}}/user/login">
{{svg "octicon-sign-in" 16}} {{.i18n.Tr "sign_in"}}
</a>
{{end}}
<a class="item{{if .PageIsSignIn}} active{{end}}" rel="nofollow" href="{{AppSubUrl}}/user/login">
{{svg "octicon-sign-in" 16}} {{.i18n.Tr "sign_in"}}
</a>
</div><!-- end anonymous right menu -->

{{end}}


+ 1
- 1
templates/org/course_list.tmpl View File

@@ -96,7 +96,7 @@
{{if .Topics }}
<div class="omit tags " style="position: relative;">
{{range .Topics}}
{{if ne . "" }}<a style="max-width:100%;margin: 5px 0;display:inline-flex;" ><span class="ui small label topic course_topic" >{{.}}</span></a>{{end}}
{{if ne . "" }}<a style="max-width:100%;margin: 5px 0;display:inline-flex;cursor:default" ><span class="ui small label topic course_topic" >{{.}}</span></a>{{end}}
{{end}}
</div>


+ 2
- 6
templates/org/home_courses.tmpl View File

@@ -136,11 +136,7 @@
<div class="ui sixteen wide mobile six wide tablet four wide computer column">
<div class=" ui bottom attached segment text center noborder text center" >
{{if .IsSigned}}
<a style="width: 80%;" class="ui green button bpadding" href="{{AppSubUrl}}/course/create"><i class="ri-folder-add-line" style="vertical-align: middle;"></i> &nbsp;{{.i18n.Tr "org.release_course"}} </a>
{{else}}
<a style="width: 80%;" class="ui green button bpadding" href="{{AppSubUrl}}/user/login"><i class="ri-folder-add-line" style="vertical-align: middle;"></i> &nbsp;{{.i18n.Tr "org.release_course"}} </a>
{{end}}
<a style="width: 80%;" class="ui green button bpadding" href="https://git.openi.org.cn/course/create" target="_blank"><i class="ri-folder-add-line" style="vertical-align: middle;"></i> &nbsp;{{.i18n.Tr "org.release_course"}} </a>
</div>
</div>
</div>
@@ -209,7 +205,7 @@
{{if .IsSigned}}
<a class="ui blue basic button" onclick="jion_course_team()" style="width: 80%;"> <i class="ri-user-add-line"></i> {{.i18n.Tr "org.teams.join_teams"}}</a>
{{else}}
<a class="ui blue basic button" href="{{AppSubUrl}}/user/login" style="width: 80%;"> <i class="ri-user-add-line"></i> {{.i18n.Tr "org.teams.join_teams"}}</a>
<a class="ui blue basic button" href="https://git.openi.org.cn/user/login?course=true" style="width: 80%;" target="_blank"> <i class="ri-user-add-line"></i> {{.i18n.Tr "org.teams.join_teams"}}</a>
{{end}}
</div>
</div>


+ 5
- 1
templates/user/auth/signin_inner.tmpl View File

@@ -29,7 +29,11 @@

<div class="ui grid">
<div class="column">
<form class="ui form" action="{{.SignInLink}}" method="post">
{{if .IsCourse}}
<form class="ui form" action="{{.SignInLink}}?course=true" method="post">
{{else}}
<form class="ui form" action="{{.SignInLink}}" method="post">
{{end}}
{{.CsrfTokenHtml}}
<div class="field">
<div class="ui left icon input {{if and (.Err_UserName) (or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeSignIn))}}error{{end}}">


Loading…
Cancel
Save