Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'phonegap-better-password'

  • Loading branch information...
commit 457ebf22a03343d4b25fe3f511528b647cb5bf2d 2 parents f431c94 + f09fed8
@struan struan authored
View
16 phonegap/www/sign_in.html → phonegap/www/account.html
@@ -11,16 +11,16 @@
<link rel="stylesheet" href="css/mobile.css">
<link rel="stylesheet" href="css/layout.css" media="(min-width:48em)">
- <script type="text/javascript" src="js/config.js"></script>
-
+ <script type="text/javascript" src="js/jquery-1.7.0.min.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova-independent.js"></script>
+ <script type="text/javascript" src="js/config.js"></script>
+ <script type="text/javascript" src="js/json2.js"></script>
+
<meta http-equiv="content-type" content="text/html; charset=utf-8">
- <script type="text/javascript" src="js/jquery-1.7.0.min.js"></script>
<script src="js/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script>
- <script type="text/javascript" src="js/json2.js"></script>
<script type="text/javascript" src="js/geo.min.js"></script>
<script type="text/javascript" src="js/fixmystreet.js"></script>
<script type="text/javascript" src="js/mobile.js"></script>
@@ -65,7 +65,7 @@
<div class="container">
<div class="content" role="main">
<form action="" method="post" name="signInForm" id="signInForm" enctype="multipart/form-data" class="validate">
- <div id="form_sign_in_only">
+ <div id="form_sign_in_only" class="nodisplay">
<div id="form_sign_in_yes" class="form-box">
<label for="form_email" id="email_label">Email</label>
<input type="email" value="" name="email" id="form_email" placeholder="Please enter your email address" required>
@@ -75,16 +75,20 @@
<input type="password" name="password_sign_in" id="password_sign_in" placeholder="Your password" value="">
<input class="green-btn" type="submit" id="submit_sign_in" name="submit_sign_in" value="Sign in">
</div>
+
</div>
</div>
</form>
+ <div id="forget_button" class="form-txt-submit-box nodisplay">
+ <input class="green-btn" type="button" id="forget" name="forget" value="Forget">
+ </div>
</div>
</div>
</div><!-- .table-cell -->
<div class="big-green-banner mobile-map-banner mobile-nav-banner">
<a href="index.html">home</a>
- Sign In
+ Account
</div>
</div> <!-- .wrapper -->
<div class="spinner" id="loadingSpinner">
View
5 phonegap/www/css/mobile.css
@@ -8,13 +8,16 @@
padding-bottom: 0;
}
+.nodisplay {
+ display: none;
+}
+
.mobile-nav-banner {
position: fixed;
background: black;
}
.mobile-sign-in-banner {
- display: none;
background: none;
}
View
2  phonegap/www/index.html
@@ -89,7 +89,7 @@
</div>
<div class="big-green-banner mobile-map-banner mobile-sign-in-banner">
- <a id="sign_in" href="sign_in.html">Sign In</a><a id="sign_out" href="#" onclick="sign_out();">Sign Out</a>
+ <a id="account" href="account.html">Account</a>
</div>
</div> <!-- .wrapper -->
View
100 phonegap/www/js/mobile.js
@@ -281,21 +281,29 @@ function postReport(e) {
service: 'iphone',
title: $('#form_title').val(),
detail: $('#form_detail').val(),
- name: $('#form_name').val(),
- may_show_name: $('#form_may_show_name').attr('checked') ? 1 : 0,
- email: $('#form_email').val(),
+ may_show_name: $('#form_may_show_name').attr('checked') ? 1 : 0,
category: $('#form_category').val(),
lat: $('#fixmystreet\\.latitude').val(),
lon: $('#fixmystreet\\.longitude').val(),
- password_sign_in: $('#password_sign_in').val(),
phone: $('#form_phone').val(),
pc: $('#pc').val()
};
- if ( submit_clicked.attr('id') == 'submit_sign_in' ) {
+ if ( localStorage.username && localStorage.password && localStorage.name ) {
+ params.name = localStorage.name;
+ params.email = localStorage.username;
+ params.password_sign_in = localStorage.password;
params.submit_sign_in = 1;
} else {
- params.submit_register = 1;
+ params.name = $('#form_name').val();
+ params.email = $('#form_email').val();
+ params.password_sign_in = $('#password_sign_in').val();
+
+ if ( submit_clicked.attr('id') == 'submit_sign_in' ) {
+ params.submit_sign_in = 1;
+ } else {
+ params.submit_register = 1;
+ }
}
showBusy( 'Sending Report', 'Please wait while your report is sent' );
@@ -330,6 +338,11 @@ function postReport(e) {
hideBusy();
window.location = 'email_sent.html';
}
+ if ( !localStorage.name && $('#password_sign_in').val() ) {
+ localStorage.name = $('#form_name').val();
+ localStorage.username = $('#form_email').val();
+ localStorage.password = $('#password_sign_in').val();
+ }
} else {
if ( data.check_name ) {
check_name( data.check_name, data.errors.name );
@@ -350,6 +363,8 @@ function postReport(e) {
function sign_in() {
showBusy( 'Signing In', 'Please wait while you are signed in' );
+ $('#form_email').blur();
+ $('#password_sign_in').blur();
jQuery.ajax( {
url: CONFIG.FMS_URL + "auth/ajax/sign_in",
type: 'POST',
@@ -362,10 +377,14 @@ function sign_in() {
console.log(data);
if ( data.name ) {
localStorage.name = data.name;
+ localStorage.username = $('#form_email').val();
+ localStorage.password = $('#password_sign_in').val();
hideBusy();
- window.location = 'signed_in.html';
- $('#sign_out').show();
- $('#sign_in').hide();
+ $('#user-meta').html('<p>You are signed in as ' + localStorage.username + '.</p>');
+ $('#form_sign_in_only').hide();
+ $('#forget_button').show();
+ $('#form_email').val('');
+ $('#password_sign_in').val('');
} else {
hideBusy();
$('#form_email').before('<div class="form-error">There was a problem with your email/password combination.</div>');
@@ -378,8 +397,17 @@ function sign_in() {
function display_signed_out_msg() {
if ( localStorage.signed_out == 1 ) {
$('#user-meta').html('<p>You&rsquo;ve been signed out.</p>');
+ $('#form_sign_in_only').show();
localStorage.signed_out = null;
}
+ if ( localStorage.name ) {
+ $('#user-meta').html('<p>You are signed in as ' + localStorage.username + '.</p>');
+ $('#form_sign_in_only').hide();
+ $('#forget_button').show();
+ } else {
+ $('#forget_button').hide();
+ $('#form_sign_in_only').show();
+ }
}
function sign_out() {
@@ -418,46 +446,12 @@ function sign_out_around() {
} );
}
-function check_auth() {
- if ( $('#user-meta').length && localStorage.signed_out != 1 ) {
- var sign_out_function = sign_out;
- if ( $('body').hasClass('mappage') ) {
- sign_out_function = sign_out_around;
- }
- jQuery.ajax( {
- url: CONFIG.FMS_URL + "auth/ajax/check_auth?" + new Date().getTime() ,
- type: 'GET',
- statusCode: {
- 200: function(data) {
- localStorage.name = data.name;
- $('#user-meta').html('<p>Hi ' + localStorage.name + '<a href="#" id="meta_sign_out">Sign out</a></p>');
- $('#meta_sign_out').on('click', sign_out_function );
- $('.mobile-sign-in-banner').show();
- $('#sign_in').hide();
- $('#sign_out').show();
- },
- 401: function() {
- $('#user-meta').html('');
- localStorage.name = '';
- $('.mobile-sign-in-banner').show();
- $('#sign_out').hide();
- $('#sign_in').show();
- $('#user-meta').html('');
- }
- }
- } );
- }
-}
-
-function signed_in() {
+function account() {
+ $('.mobile-sign-in-banner').show();
+ $('#account').show();
if ( localStorage.name ) {
if ( $('body').hasClass('signed-in-page') ) {
- var sign_out_function = sign_out;
- if ( $('body').hasClass('mappage') ) {
- sign_out_function = sign_out_around;
- }
- $('#user-meta').html('<p>Hi ' + localStorage.name + '<a href="#" id="meta_sign_out">Sign out</a></p>');
- $('#meta_sign_out').on('click', sign_out_function );
+ $('#user-meta').html('<p>Hi ' + localStorage.name + '</p>');
}
if ( $('#form_sign_in').length ) {
@@ -467,6 +461,14 @@ function signed_in() {
}
}
+function forget() {
+ delete localStorage.name;
+ delete localStorage.username;
+ delete localStorage.password;
+ localStorage.signed_out = 1;
+ display_signed_out_msg();
+}
+
function onDeviceReady() {
var location = document.location + '';
if ( location.indexOf('no_connection.html') < 0 && (
@@ -478,9 +480,9 @@ function onDeviceReady() {
$('#mapForm').submit(postReport);
$('#signInForm').submit(sign_in);
$('#ffo').click(getPosition);
+ $('#forget').click(forget);
$('#mapForm :input[type=submit]').on('click', function() { submit_clicked = $(this); });
- check_auth();
- signed_in();
+ account();
hideBusy();
}
View
83 phonegap/www/signed_in.html
@@ -1,83 +0,0 @@
-<!doctype html>
-<html class="no-js" lang="en-gb">
- <head>
- <meta name="viewport" content="initial-scale=1.0">
-
- <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
- <meta name="HandHeldFriendly" content="true">
- <meta name="mobileoptimized" content="0">
-
- <link rel="stylesheet" href="css/base.css">
- <link rel="stylesheet" href="css/mobile.css">
- <link rel="stylesheet" href="css/layout.css" media="(min-width:48em)">
-
- <script type="text/javascript" src="js/config.js"></script>
-
- <script type="text/javascript" charset="utf-8" src="cordova-independent.js"></script>
-
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <script type="text/javascript" src="js/jquery-1.7.0.min.js"></script>
-
- <script src="js/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script>
-
- <script type="text/javascript" src="js/json2.js"></script>
- <script type="text/javascript" src="js/geo.min.js"></script>
- <script type="text/javascript" src="js/fixmystreet.js"></script>
- <script type="text/javascript" src="js/mobile.js"></script>
- <script type="text/javascript" src="js/OpenLayers.fixmystreet.js"></script>
- <script type="text/javascript" src="js/map-OpenLayers.js"></script>
- <script type="text/javascript" src="js/map-bing-ol.js"></script>
- <script type="text/javascript" src="js/jquery.ba-hashchange.min.js"></script>
-
- <script type="text/javascript">
- validation_strings = {
- update: 'Please enter a message',
- title: 'Please enter a subject',
- detail: 'Please enter some details',
- name: {
- required: 'Please enter your name',
- validName: 'Please enter your full name, councils need this information – if you do not wish your name to be shown on the site, untick the box below'
- },
- category: 'Please choose a category',
- rznvy: {
- required: 'Please enter your email',
- email: 'Please enter a valid email'
- },
- email: {
- required: 'Please enter your email',
- email: 'Please enter a valid email'
- }
- };
- </script>
- <title> Viewing a location :: FixMyStreet </title>
- </head>
-
- <body class="mobile-header signed-in-page" id="container">
-
- <div class="wrapper">
- <div class="table-cell">
- <header id="site-header" role="banner">
- <div class="container">
- <span id="site-logo"></span>
- </div>
- </header>
-
- <div id="user-meta">
-
- </div>
-
- <div class="container">
- <div class="content" role="main">
-
- </div><!-- .content role=main -->
- </div><!-- .container -->
- </div><!-- .table-cell -->
-
- <div class="big-green-banner mobile-map-banner mobile-nav-banner">
- <a href="index.html">home</a>
- Signed In
- </div>
-
- </div> <!-- .wrapper -->
-</body>
-</html>
Please sign in to comment.
Something went wrong with that request. Please try again.