forked from community/product-iots
parent
306646c51d
commit
36bf7a529a
@ -0,0 +1,200 @@
|
||||
<%
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
var configs = require('/config/sso.js').config();
|
||||
var e = request.getParameter('authFailure');
|
||||
|
||||
var log = new Log();
|
||||
var relyingParty = request.getParameter('relyingParty');
|
||||
|
||||
if(!request.isSecure()){
|
||||
response.content = { 'authFailure' : e , 'relyingParty' : relyingParty };
|
||||
response.sendRedirect(configs.server.https + request.getRequestURI());
|
||||
}
|
||||
|
||||
//TODO: this should be fixed properly
|
||||
if (relyingParty instanceof Array) {
|
||||
relyingParty = relyingParty.pop();
|
||||
}
|
||||
var signInUrl;
|
||||
|
||||
if (relyingParty == 'publisher') {
|
||||
signInUrl = configs.urls.publisher;
|
||||
} else {
|
||||
signInUrl = configs.urls.store + '/login?ignoreReferer=true';
|
||||
}
|
||||
|
||||
var recoveryModule = require('account-management').recovery;
|
||||
var challengeSet = recoveryModule.getChallengeQuestionSet();
|
||||
var isPasswordRecoveryEnabled = recoveryModule.isPasswordRecoveryEnabled();
|
||||
var themeModule = require('/modules/theme.js');
|
||||
%>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Sign in or Register | <% include(themeModule.getThemedUrl('includes/title.jag')); %></title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
<% include(themeModule.getThemedUrl('includes/header_file_imports.jag')); %>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<% include(themeModule.getThemedUrl('includes/header.jag')); %>
|
||||
<div class="row">
|
||||
<!-- content -->
|
||||
<div class="col-xs-12 col-sm-10 col-md-8 col-lg-5 col-centered wr-login">
|
||||
<form id="registerForm">
|
||||
<h2 class="wr-title uppercase blue-bg padding-double white boarder-bottom-blue margin-none">Create An Account</h2>
|
||||
<div class="clearfix"></div>
|
||||
<div class="boarder-all ">
|
||||
<div class="padding-double font-large">Enter all text fields to complete registration </div>
|
||||
<!-- validation -->
|
||||
<div class="padding-double">
|
||||
<div id="regFormError" class="alert alert-error" style="display:none"></div>
|
||||
<div id="regFormSuc" class="alert alert-success" style="display:none"></div>
|
||||
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 form-group">
|
||||
<label>Username</label>
|
||||
<input id="reg-username" name="reg-username" type="text" class="form-control required usrName usrNameLength">
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 form-group">
|
||||
<label>Password</label>
|
||||
<input id="reg-password" name="reg-password" type="password" class="form-control required passwordLength">
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 form-group">
|
||||
<label>Confirm password</label>
|
||||
<input id="reg-password2" name="password2" type="password" class="form-control required" equalTo="#reg-password">
|
||||
</div>
|
||||
|
||||
<%
|
||||
var claimsModule = require('account-management');
|
||||
var claims = claimsModule.getDefaultClaims();
|
||||
var renderedClaims = {};
|
||||
|
||||
var claimUriOverrides = {
|
||||
USERNAME: {
|
||||
render: false // because this is already rendered by default
|
||||
},
|
||||
PASSWORD: {
|
||||
render: false // because this is already rendered by default
|
||||
},
|
||||
EMAILADDRESS: {
|
||||
render: true,
|
||||
customClass: 'email'
|
||||
}
|
||||
};
|
||||
|
||||
for (var claimIndex = 0; claimIndex < claims.length; claimIndex++) {
|
||||
var override = claimUriOverrides[claims[claimIndex].claimUri.toUpperCase()];
|
||||
// render claim if it's required and not overriden to --> render:false
|
||||
if (claims[claimIndex].isRequired && (!override || override.render !== false)) {
|
||||
var formElementName = 'reg-' + claims[claimIndex].displayTag.toLowerCase().replace(' ', '-');
|
||||
var validationClass = "";
|
||||
var span = "";
|
||||
if(claims[claimIndex].displayTag == "Email"){
|
||||
validationClass = "email";
|
||||
span = "col-xs-12 col-sm-12 col-md-12 col-lg-12";
|
||||
}else{
|
||||
span = "col-xs-12 col-sm-12 col-md-6 col-lg-6"
|
||||
}
|
||||
%>
|
||||
<div class="<%=span%> form-group">
|
||||
<label><%=claims[claimIndex].displayTag%></label>
|
||||
<input type="text" name="<%=formElementName%>" data-claim-uri="<%=claims[claimIndex].claimUri%>" class="form-control <%=validationClass%> required <%=claims[claimIndex].customClass%>">
|
||||
</div>
|
||||
<%
|
||||
renderedClaims[formElementName] = claims[claimIndex].claimUri;
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
<input type="hidden" name="reg-claims" value='<%=renderedClaims%>'
|
||||
class="input-block-level required">
|
||||
<input id="reg-action" name="action" type="hidden" value="register">
|
||||
<input id="reg-relyingParty" name="relyingParty" type="hidden" value="<%=relyingParty%>">
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 form-group">
|
||||
<br/><br/>
|
||||
<button id="registrationSubmit" class="wr-btn grey-bg col-xs-12 col-md-12 col-lg-12 uppercase font-extra-large"
|
||||
type="button">Register
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 form-group">
|
||||
<span class="margin-top padding-top-double font-large">Already have an account? </span>
|
||||
<a href="<%=signInUrl%>" id="signInLink" class="font-large">Sign in</a>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% include(themeModule.getThemedUrl('includes/footer_file_imports.jag')); %>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var ENTER_KEY = 13;
|
||||
function register() {
|
||||
if (!$('#registerForm').valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var formData = $("#registerForm").serialize();
|
||||
|
||||
$.post('/sso/register', formData, function (data) {
|
||||
var regFormError = $('#regFormError');
|
||||
var regFromSuccess = $('#regFormSuc');
|
||||
if (JSON.parse(data).error == 'false') {
|
||||
regFormError.hide();
|
||||
regFromSuccess.show();
|
||||
regFromSuccess.text(JSON.parse(data).msg + ". You will be redirected to login page.");
|
||||
setTimeout(function () {
|
||||
window.location = "<%=signInUrl%>";
|
||||
}, 2000);
|
||||
} else {
|
||||
regFromSuccess.hide();
|
||||
regFormError.show();
|
||||
regFormError.text(JSON.parse(data).msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("#registrationSubmit").bind('click', register);
|
||||
|
||||
$('#registerForm input').bind('keypress', function (e) {
|
||||
if (e.which == ENTER_KEY) {
|
||||
register();
|
||||
}
|
||||
});
|
||||
|
||||
jQuery.validator.addMethod("usrName", function (value, element) {
|
||||
return this.optional(element) || /^[a-zA-Z0-9\-\@\.]*$/.test(value);
|
||||
}, "Only alphanumeric characters and '-' allowed");
|
||||
jQuery.validator.addMethod("usrNameLength", function (value, element) {
|
||||
return value.length >= 3 && value.length <= 30;
|
||||
}, "username must contain minimum 3 characters and maximum 30 characters");
|
||||
jQuery.validator.addMethod("passwordLength", function (value, element) {
|
||||
return this.optional(element) || /^[\S]{5,30}$/.test(value);
|
||||
}, "Password must contain minimum 5 characters and maximum 30 characters");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in new issue