This repository has been archived by the owner on May 7, 2020. It is now read-only.
forked from HenryHoggard/Cryptospora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.js
121 lines (98 loc) · 3.87 KB
/
login.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
$(function() {
$('#commit').click(function() { // press Login
var username = $('#username').val();
var password = $('#password').val();
// get an authenticity token
function getToken()
{
$.ajax
({
async: false,
type: 'GET',
url: 'https://pod.cscf.me/users/sign_in',
success: function(data)
{
var matches = data.match(/<meta content="(.*)" name="csrf-token" \/>/); // regex to extract it,
// if there are no matches, it must be a self message
tok = matches[1];
result = tok;
}
});
return result;
}
var authenticity_token = getToken();
<<<<<<< HEAD
var utf = "%E2%9C%93";
=======
>>>>>>> 4305789d1aa241b81da6c1254be23ab8a1b90218
//alert(authenticity_token);
//alert(username);
//alert(password);
// utf8=%E2%9C%93&authenticity_token=JVMo0sD9Qww93i58KCe98vrrZpuHKqYQ4CPO8RMFXAc%3D&user%5Busername%5D=sam&user%5Bpassword%5D=worth22&commit=Sign+in
//var pod = document.getElementsByName('podName');
if (username.value == "") {
$('#loginError').fadeOut();
$('#loginError').empty();
$('#loginError').append('<div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">×</button>Please enter an email address!</div>');
$('#loginError').fadeIn();
}
else if (password.value == "") {
$('#loginError').fadeOut();
$('#loginError').empty();
$('#loginError').append('<div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">×</button>Please enter a password</div>');
$('#loginError').fadeIn();
}
// if all data is present...
else{
<<<<<<< HEAD
//post the login details
var dataToSend = 'utf8' +utf +'authenticity_token=' + authenticity_token +'&user[username]=' + username +'&user[password]='+ password + '&commit=Sign+in';
=======
//post the login details
var dataToSend = 'authenticity_token=' + authenticity_token +'&user[username]=' + username +'&user[password]='+ password + '&commit=Sign+in';
>>>>>>> 4305789d1aa241b81da6c1254be23ab8a1b90218
var dataToSend2 = JSON.stringify(dataToSend);
//alert(dataToSend2);
//var dataToSend = 'utf8=E29C93&authenticity_token=Wpy61blxjdZx3K8tB9aArqUZOaBwfl5eCBNNM235j34=&user[username]=sam&user[password]=worth22&commit=Sign+in';
//alert (dataToSend);
$.ajax({
url: "https://pod.cscf.me/users/sign_in",
type: "POST",
data: dataToSend,
cache: false,
success: function(php_output) {
<<<<<<< HEAD
window.location.replace("inbox.html");
=======
>>>>>>> 4305789d1aa241b81da6c1254be23ab8a1b90218
//$("#testDummy").html(php_output);
// check if login was successfull
var loginMsg = php_output.match(/Invalid email or password./);
var outputErrorMsg="Invalid email or password.";
if(loginMsg == outputErrorMsg){
$('#loginError').fadeOut();
$('#loginError').empty();
$('#loginError').append('<div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">×</button>Invalid username or password!</div>');
$('#loginError').fadeIn();
}
var SuccessfullloginMsg = php_output.match(/Signed in successfully./);
var goodLoginMsg="Signed in successfully.";
if(SuccessfullloginMsg == goodLoginMsg){
// go to inbox page
window.location.replace("inbox.html");
}
<<<<<<< HEAD
=======
>>>>>>> 4305789d1aa241b81da6c1254be23ab8a1b90218
},
error: function(){
$('#loginError').fadeOut();
$('#loginError').empty();
$('#loginError').append('<div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">×</button>Connection Error. Contact Support or restart extention.</div>');
$('#loginError').fadeIn();
}
});
}
return false;
});
});