only show gitlab signup/login links if gitlab oauth is turned on

This commit is contained in:
JoramWilander
2015-07-22 15:32:39 -04:00
parent 41bbbbf446
commit 56a0a7d1e1
9 changed files with 46 additions and 14 deletions
+3 -3
View File
@@ -28,9 +28,9 @@
"Allow": false,
"Secret" : "",
"Id": "",
"AuthEndpoint": "<yourgitlabdomain>/oauth/authorize",
"TokenEndpoint": "<yourgitlabdomain>/oauth/token",
"UserApiEndpoint": "<yourgitlabdomain>/api/v3/user"
"AuthEndpoint": "",
"TokenEndpoint": "",
"UserApiEndpoint": ""
}
},
"SqlSettings": {
+11
View File
@@ -253,3 +253,14 @@ func IsS3Configured() bool {
return true
}
func GetAllowedAuthServices() []string {
authServices := []string{}
for name, service := range Cfg.SSOSettings {
if service.Allow {
authServices = append(authServices, name)
}
}
return authServices
}
+12 -3
View File
@@ -90,6 +90,17 @@ module.exports = React.createClass({
focusEmail = true;
}
var auth_services = JSON.parse(this.props.authServices);
var login_message;
if (auth_services.indexOf("gitlab") >= 0) {
login_message = (
<div className="form-group form-group--small">
<span><a href={"/"+teamName+"/login/gitlab"}>{"Log in with GitLab"}</a></span>
</div>
);
}
return (
<div className="signup-team__container">
<div>
@@ -112,9 +123,7 @@ module.exports = React.createClass({
<div className="form-group">
<button type="submit" className="btn btn-primary">Sign in</button>
</div>
<div className="form-group form-group--small">
<span><a href={"/"+teamName+"/login/gitlab"}>{"Log in with GitLab"}</a></span>
</div>
{ login_message }
<div className="form-group form-group--small">
<span><a href="/find_team">{"Find other " + strings.TeamPlural}</a></span>
</div>
+12 -2
View File
@@ -103,7 +103,7 @@ module.exports = React.createClass({
var yourEmailIs = this.state.user.email == "" ? "" : <span>Your email address is { this.state.user.email }. </span>
var email =
var email = (
<div className={ this.state.original_email == "" ? "" : "hidden"} >
<label className="control-label">Email</label>
<div className={ email_error ? "form-group has-error" : "form-group" }>
@@ -111,6 +111,16 @@ module.exports = React.createClass({
{ email_error }
</div>
</div>
);
var auth_services = JSON.parse(this.props.authServices);
var signup_message;
if (auth_services.indexOf("gitlab") >= 0) {
signup_message = <p>{"Choose your username and password for the " + this.props.teamDisplayName + " " + strings.Team} <a href={"/"+this.props.teamName+"/signup/gitlab"+window.location.search}>{"or sign up with GitLab."}</a></p>;
} else {
signup_message = <p>{"Choose your username and password for the " + this.props.teamDisplayName + " " + strings.Team + "."}</p>;
}
return (
<div>
@@ -119,7 +129,7 @@ module.exports = React.createClass({
<div className="form-group form-group--small">
<span></span>
</div>
<p>{"Choose your username and password for the " + this.props.teamDisplayName + " " + strings.Team} <a href={"/"+this.props.teamName+"/signup/gitlab"+window.location.search}>{"or sign up with GitLab."}</a></p>
{ signup_message }
<p>Your username can be made of lowercase letters and numbers.</p>
<label className="control-label">Username</label>
<div className={ name_error ? "form-group has-error" : "form-group" }>
+2 -2
View File
@@ -3,9 +3,9 @@
var Login = require('../components/login.jsx');
global.window.setup_login_page = function(teamDisplayName, teamName) {
global.window.setup_login_page = function(team_display_name, team_name, auth_services) {
React.render(
<Login teamDisplayName={teamDisplayName} teamName={teamName}/>,
<Login teamDisplayName={team_display_name} teamName={team_name} authServices={auth_services} />,
document.getElementById('login')
);
};
+2 -2
View File
@@ -3,9 +3,9 @@
var SignupUserComplete =require('../components/signup_user_complete.jsx');
global.window.setup_signup_user_complete_page = function(email, name, ui_name, id, data, hash) {
global.window.setup_signup_user_complete_page = function(email, name, ui_name, id, data, hash, auth_services) {
React.render(
<SignupUserComplete teamId={id} teamName={name} teamDisplayName={ui_name} email={email} hash={hash} data={data} />,
<SignupUserComplete teamId={id} teamName={name} teamDisplayName={ui_name} email={email} hash={hash} data={data} authServices={auth_services} />,
document.getElementById('signup-user-complete')
);
};
+1 -1
View File
@@ -20,7 +20,7 @@
</div>
</div>
<script>
window.setup_login_page({{.Props.TeamDisplayName}}, {{.Props.TeamName}});
window.setup_login_page('{{.Props.TeamDisplayName}}', '{{.Props.TeamName}}', '{{.Props.AuthServices}}');
</script>
</body>
</html>
+1 -1
View File
@@ -19,7 +19,7 @@
</div>
</div>
<script>
window.setup_signup_user_complete_page('{{.Props.Email}}', '{{.Props.TeamName}}', '{{.Props.TeamDisplayName}}', '{{.Props.TeamId}}', '{{.Props.Data}}', '{{.Props.Hash}}');
window.setup_signup_user_complete_page('{{.Props.Email}}', '{{.Props.TeamName}}', '{{.Props.TeamDisplayName}}', '{{.Props.TeamId}}', '{{.Props.Data}}', '{{.Props.Hash}}', '{{.Props.AuthServices}}');
</script>
</body>
</html>
+2
View File
@@ -188,6 +188,7 @@ func login(c *api.Context, w http.ResponseWriter, r *http.Request) {
page := NewHtmlTemplatePage("login", "Login")
page.Props["TeamDisplayName"] = team.DisplayName
page.Props["TeamName"] = teamName
page.Props["AuthServices"] = model.ArrayToJson(utils.GetAllowedAuthServices())
page.Render(c, w)
}
@@ -274,6 +275,7 @@ func signupUserComplete(c *api.Context, w http.ResponseWriter, r *http.Request)
page.Props["TeamId"] = props["id"]
page.Props["Data"] = data
page.Props["Hash"] = hash
page.Props["AuthServices"] = model.ArrayToJson(utils.GetAllowedAuthServices())
page.Render(c, w)
}