| @@ -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. | |||
| @@ -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 { | |||
| @@ -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}} | |||
| @@ -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> | |||
| @@ -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> {{.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> {{.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> {{.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> | |||
| @@ -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}}"> | |||