summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--css/codeq.css2
-rw-r--r--index.html40
-rw-r--r--js/codeq/aaiLogin.js14
-rw-r--r--js/codeq/change_password.js7
-rw-r--r--js/codeq/comms.js6
-rw-r--r--js/codeq/login.js27
-rw-r--r--js/codeq/signup.js7
-rw-r--r--js/codeq/upgrade_to_aai.js58
-rw-r--r--res/en.json7
-rw-r--r--res/sl.json7
10 files changed, 146 insertions, 29 deletions
diff --git a/css/codeq.css b/css/codeq.css
index ba10bcd..9d056c7 100644
--- a/css/codeq.css
+++ b/css/codeq.css
@@ -33,7 +33,7 @@ body {
}
/* modal screens*/
-#screen_login, #screen_signup, #screen_change_pass, #screen_settings {
+#screen_login, #screen_signup, #screen_change_pass, #screen_settings, #screen_upgrade_to_aai {
padding: 15px 0;
}
diff --git a/index.html b/index.html
index b5e8e89..65edb18 100644
--- a/index.html
+++ b/index.html
@@ -233,6 +233,45 @@
</div>
</div>
+
+ <!-- upgrade account to AAI screen -->
+ <div class="container" id="screen_upgrade_to_aai" style="display: none;">
+ <div class="row">
+ <div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h3 class="text-center" data-tkey="upgrade_to_aai_header">Upgrade to AAI?</h3>
+ </div>
+ <div class="panel-body">
+ <form id="formUpgradeToAAI" class="form">
+ <div data-tkey="upgrade_to_aai_body_text_1">
+ <p>User with this email address already exists.</p>
+ <p>Enter its password and select <span class="badge">Yes</span> to upgrade it to AAI.</p>
+ </div>
+ <div class="form-group">
+ <label class="sr-only" for="password" data-tkey="password">Password</label>
+ <input type="password" class="form-control" name="password" id="formUpgradeToAAIPassword" data-tkey-placeholder="password" placeholder="Password" required>
+ </div>
+ <div data-tkey="upgrade_to_aai_body_text_2">
+ <p>Select <span class="badge">No</span> to do a separate account.</p>
+ </div>
+ </form>
+ </div>
+ <div class="panel-footer text-center">
+ <div>
+ <button class="btn btn-default" id="btnUpgradeToAAINo" data-tkey="upgrade_to_aai_no_button">No, make new</button>
+ <input form="formUpgradeToAAI" class="btn btn-primary" id="btnUpgradeToAAIYes" type="submit" data-tkey-value="upgrade_to_aai_yes_button" value="Yes, upgrade to AAI"></button>
+ </div>
+ <br>
+ <div class="text-center small">
+ <a role="button" onclick="codeq.setLang('sl')">Slovenščina</a> | <a role="button" onclick="codeq.setLang('en')">English</a>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
<!-- main screen: programming language selection, settings, etc. -->
<div class="container" id="screen_language" style="text-align: center; display: none;">
<div class="row">
@@ -490,6 +529,7 @@
<script src="js/codeq/signup.js"></script>
<script src="js/codeq/login.js"></script>
<script src="js/codeq/aaiLogin.js"></script>
+ <script src="js/codeq/upgrade_to_aai.js"></script>
<script src="js/codeq/change_password.js"></script>
<script src="js/codeq/profile.js"></script>
<script src="js/codeq/language.js"></script>
diff --git a/js/codeq/aaiLogin.js b/js/codeq/aaiLogin.js
index 5d4f1c9..ced3b0c 100644
--- a/js/codeq/aaiLogin.js
+++ b/js/codeq/aaiLogin.js
@@ -3,7 +3,8 @@
*/
(function(){
- var jqNavBarRight = $('.nav.navbar-nav.navbar-right'),
+ var jqScreen = $('#screen_aai_login'),
+ jqNavBarRight = $('.nav.navbar-nav.navbar-right'),
jqNavigationHomeBtn = $('#navigation-home'),
jqCancelAaiLogin = $("#cancel_aai_login"),
jqDisabledOverlay = $('#disabled'),
@@ -25,7 +26,7 @@
});
$('#signed-in-title').html('');
- $('#screen_aai_login').css('display','');
+ jqScreen.css('display','');
codeq.comms.connect()
.then(function(){
@@ -33,7 +34,12 @@
jqAaiIframe.attr('src', samlLoginUrl);
return codeq.comms.samlLogin();
})
- .then(codeq.loginCallbackFunction)
+ .then(function(data){
+ //upgrade
+ if (data.code == 1) codeq.globalStateMachine.transition('upgradeToAAI');
+ //not upgrade
+ else codeq.loginCallbackFunction(data);
+ })
.fail(function(reason){
if(codeq.samlLogin){//if the user goes back to the normal login screen the timeout (which will happen) mustn't do anything
codeq.log.error('SAML login failed: ' + reason);
@@ -52,7 +58,7 @@
jqCancelAaiLogin.off('click');
samlLoginUrl = '';
- $("#screen_aai_login").css('display', 'none');
+ jqScreen.css('display', 'none');
//re-enable the click listener of the logo
jqNavigationHomeBtn.on('click', function(e){
diff --git a/js/codeq/change_password.js b/js/codeq/change_password.js
index c08c2d2..6bba0e9 100644
--- a/js/codeq/change_password.js
+++ b/js/codeq/change_password.js
@@ -3,7 +3,8 @@
*/
(function(){
- var jqNew = $("#modalChangePasswordNew"),
+ var jqScreen = $("#screen_change_pass"),
+ jqNew = $("#modalChangePasswordNew"),
jqVerify = $("#modalChangePasswordVerify"),
jqCancelBtn = $("#cancel_change_pass_button"),
jqChangePassForm = $('#formChangePassword');
@@ -35,13 +36,13 @@
});
- $("#screen_change_pass").css('display', '');
+ jqScreen.css('display', '');
$('#disabled').css('display', 'none');
},
'exit' : function(){
jqChangePassForm.off('submit');
jqCancelBtn.off('click');
- $("#screen_change_pass").css('display', 'none');
+ jqScreen.css('display', 'none');
jqNew.val('');
jqVerify.val('');
}
diff --git a/js/codeq/comms.js b/js/codeq/comms.js
index 306263c..b5296a8 100644
--- a/js/codeq/comms.js
+++ b/js/codeq/comms.js
@@ -533,8 +533,10 @@
return ajaxGet(ajaxDataPrefix + 'resources.json');
},
- 'samlLogin': function(){
- return this.send({'action':'saml_login','gui_lang':codeq.getLang()});
+ 'samlLogin': function(upgrade_account, upgrade_password){
+ if (upgrade_account === undefined) return this.send({'action':'saml_login','gui_lang':codeq.getLang()});
+ else if (upgrade_account) return this.send({'action':'saml_login','gui_lang':codeq.getLang(), 'upgrade_account': true, 'upgrade_password': upgrade_password});
+ else return this.send({'action':'saml_login','gui_lang':codeq.getLang(), 'upgrade_account': false});
},
'samlLogout': function(){
diff --git a/js/codeq/login.js b/js/codeq/login.js
index b2c39dd..9d899c6 100644
--- a/js/codeq/login.js
+++ b/js/codeq/login.js
@@ -3,17 +3,18 @@
*/
(function(){
- var jqNavBarRight = $('.nav.navbar-nav.navbar-right'),
+ var jqScreen = $("#screen_login"),
+ jqNavBarRight = $('.nav.navbar-nav.navbar-right'),
jqNavigationHomeBtn = $('#navigation-home'),
jqAAILoginBtn = $('#aai_login_button'),
jqSignupBtn = $('#signup_button'),
jqSubmitLoginBtn = $("#submit"),
- jqDisabled = $('#disabled');
+ jqDisabledOverlay = $('#disabled');
//the loginCallbackFunction is used here and in the AAI login as well
codeq.loginCallbackFunction = function (data) {
- jqDisabled.css('display', 'none');
- jqDisabled.css('cursor', '');
+ jqDisabledOverlay.css('display', 'none');
+ jqDisabledOverlay.css('cursor', '');
if (data.code !== 0) throw new Error('Login failed, code: ' + data.code + ', message: ' + data.message);
//nav signed in...
@@ -39,23 +40,21 @@
}
codeq.globalStateMachine.transition('language');
- //codeq.activateState('language');
};
var loginFun = function(){
- jqDisabled.css('display', '');
- jqDisabled.css('cursor', 'wait');
+ jqDisabledOverlay.css('display', '');
+ jqDisabledOverlay.css('cursor', 'wait');
codeq.comms.connect()
.then(function () {
return codeq.comms.login($('#username').val(), $('#password').val());
})
.then(codeq.loginCallbackFunction)
.fail(function (reason) {
- jqDisabled.css('display', 'none');
- jqDisabled.css('cursor', '');
- codeq.log.error('Login failed: ' + reason, reason);
+ jqDisabledOverlay.css('display', 'none');
+ jqDisabledOverlay.css('cursor', '');
+ codeq.log.error('Login failed: ' + reason);
alert('Login request failed: ' + reason);
- jqDisabled.css('display', 'none');
})
.done();
},
@@ -88,8 +87,8 @@
}
});
//$('#modalLogIn').modal();
- $("#screen_login").css('display', '');
- jqDisabled.css('display', 'none');
+ jqScreen.css('display', '');
+ jqDisabledOverlay.css('display', 'none');
},
'exit' : function(){
//remove the listener from the buttons specific to this page
@@ -98,7 +97,7 @@
jqSignupBtn.off('click');
jqAAILoginBtn.off('click');
- $("#screen_login").css('display', 'none');
+ jqScreen.css('display', 'none');
$("#password").val('');
//re-enable the click listener
jqNavigationHomeBtn.on('click', function(e){
diff --git a/js/codeq/signup.js b/js/codeq/signup.js
index bafd690..443b500 100644
--- a/js/codeq/signup.js
+++ b/js/codeq/signup.js
@@ -3,7 +3,8 @@
*/
(function(){
- var jqUsername = $("#modalSignUpUsername"),
+ var jqScreen = $("#screen_signup"),
+ jqUsername = $("#modalSignUpUsername"),
jqName = $("#modalSignUpName"),
jqEmail = $("#modalSignUpEmail"),
jqPassword = $("#modalSignUpPassword"),
@@ -18,7 +19,7 @@
jqNavigationHomeBtn.off('click');//remove the click listener of this element here
jqNavBarRight.css('display','none');//hide settings etc.
$('#signed-in-title').html('');
- $("#screen_signup").css('display', '');
+ jqScreen.css('display', '');
$('#disabled').css('display', 'none');
jqExitSignUpBtn.on('click',function(){
codeq.globalStateMachine.transition('login');
@@ -53,7 +54,7 @@
});
},
'exit' : function(){
- $("#screen_signup").css('display', 'none');
+ jqScreen.css('display', 'none');
//re-enable the click listener
jqNavigationHomeBtn.on('click', function(e){
codeq.globalStateMachine.transition('language');
diff --git a/js/codeq/upgrade_to_aai.js b/js/codeq/upgrade_to_aai.js
new file mode 100644
index 0000000..31c581a
--- /dev/null
+++ b/js/codeq/upgrade_to_aai.js
@@ -0,0 +1,58 @@
+/**
+ * Created by markop on 11/02/15.
+ */
+(function(){
+
+ var jqScreen = $("#screen_upgrade_to_aai"),
+ jqForm = $('#formUpgradeToAAI'),
+ jqNoBtn = $('#btnUpgradeToAAINo'),
+ jqPassword = $('#formUpgradeToAAIPassword') ;
+
+ codeq.globalStateMachine.register('upgradeToAAI',{
+ 'enter': function(){
+ jqNoBtn.on('click',function(){
+ codeq.comms.samlLogin(false)
+ .then(codeq.loginCallbackFunction)
+ .fail(function(reason){
+ if(codeq.samlLogin){//if the user goes back to the normal login screen the timeout (which will happen) mustn't do anything
+ codeq.log.error('SAML login failed: ' + reason);
+ alert('SAML login failed: ' + reason);
+ codeq.globalStateMachine.transition('login');
+ }
+ })
+ .done();
+ });
+ jqForm.on('submit',function(event) {
+ event.preventDefault(); // Prevent the form from submitting via the browser.
+ codeq.comms.samlLogin(true, jqPassword.val())
+ .then(function(data){
+ // password does not match
+ if (data.code == 4) {
+ codeq.log.error('code: ' + data.code + ', message: ' + data.message);
+ alert('Password does not match. Enter right password or select No.');
+ }
+ //ok or other
+ else codeq.loginCallbackFunction(data);
+ })
+ .fail(function(reason){
+ if(codeq.samlLogin){//if the user goes back to the normal login screen the timeout (which will happen) mustn't do anything
+ codeq.log.error('SAML login failed: ' + reason);
+ alert('SAML login failed: ' + reason);
+ codeq.globalStateMachine.transition('login');
+ }
+ })
+ .done();
+
+ });
+ jqScreen.css('display', '');
+ $('#disabled').css('display', 'none');
+ },
+ 'exit' : function(){
+ jqNoBtn.off('click');
+ jqForm.off('submit');
+ jqScreen.css('display', 'none');
+ jqPassword.val('');
+ }
+ });
+
+})();
diff --git a/res/en.json b/res/en.json
index f560b15..a14b522 100644
--- a/res/en.json
+++ b/res/en.json
@@ -56,5 +56,10 @@
"layout_select": "Layout",
"line_layout": "Line",
"square_layout": "Square",
- "settings_cancel_btn": "Close"
+ "settings_cancel_btn": "Close",
+ "upgrade_to_aai_header": "Upgrade to AAI?",
+ "upgrade_to_aai_body_text_1": "<p>User with this email address already exists.</p><p>Enter its password and select <span class=\"badge\">Yes</span> to upgrade it to AAI.</p>",
+ "upgrade_to_aai_body_text_2": "<p>Select <span class=\"badge\">No</span> to do a separate account.</p>",
+ "upgrade_to_aai_no_button": "No, make new",
+ "upgrade_to_aai_yes_button": "Yes, upgrade to AAI"
}
diff --git a/res/sl.json b/res/sl.json
index d99721a..54ca079 100644
--- a/res/sl.json
+++ b/res/sl.json
@@ -56,5 +56,10 @@
"layout_select": "Razporeditev",
"line_layout": "Vrstična",
"square_layout": "Štirikotna",
- "settings_cancel_btn": "Zapri"
+ "settings_cancel_btn": "Zapri",
+ "upgrade_to_aai_header": "Nadgradnja na AAI?",
+ "upgrade_to_aai_body_text_1": "<p>Uporabnik s tem e-poštnim naslovom že obstaja.</p><p> Vnesite geslo in izberite <span class=\"badge\">Da</span>, da ga nadgradite na AAI.</p>",
+ "upgrade_to_aai_body_text_2": "<p>Izberite <span class=\"badge\">Ne</span>, če želite narediti poseben račun.</p>",
+ "upgrade_to_aai_no_button": "Ne, naredite novega",
+ "upgrade_to_aai_yes_button": "Da, nadgradite na AAI"
}