Remove heroku support from web

pull/1/head
hikari.ftg 2022-03-22 15:19:37 +00:00
parent 041960117f
commit c5e7cff689
1 changed files with 255 additions and 291 deletions

View File

@ -28,8 +28,6 @@
user-select: none; user-select: none;
} }
.button:hover { .button:hover {
box-shadow: inset 5px 5px 3px rgba(255, 255, 255, .1), box-shadow: inset 5px 5px 3px rgba(255, 255, 255, .1),
inset -5px -5px 3px rgba(255, 255, 255, .1); inset -5px -5px 3px rgba(255, 255, 255, .1);
@ -71,7 +69,6 @@
} }
body { body {
/*background: linear-gradient(-45deg, #007700 0%, #004400 100%);*/
transition: all 2s ease; transition: all 2s ease;
background: #16181d; background: #16181d;
} }
@ -303,24 +300,24 @@
</div> </div>
<div class="blur"> <div class="blur">
<div class="title">Hikka</div> <div class="title">Hikka</div>
<div class="description">Ultimate userbot.<br>Best <span style="color:#28a0dc">Telegram</span> userbot.<br><b>Ever</b>.</div> <div class="description">Fresh and cute<br><span style="color:#28a0dc">Telegram</span> userbot.</div>
<div class="center"> <div class="center">
<div class="button" id="get_started">Get started</div> <div class="button" id="get_started">Get started</div>
<span id="block_api_id"> <span id="block_api_id">
<label class="api_id" for="api_id">API ID: </label> <label class="api_id" for="api_id">Telegram API ID: </label>
<input class="api_id" id="api_id" placeholder="2020" style="width: 4em;"> <input class="api_id" id="api_id" placeholder="xxxx" style="width: 4em;">
</span> </span>
<span id="block_api_hash"> <span id="block_api_hash">
<label class="api_hash" for="api_hash">API HASH: </label> <label class="api_hash" for="api_hash">Telegram API hash: </label>
<input class="api_hash" id="api_hash" placeholder="w7i07l02i6hymgg03ncq6esmr3t4c9kl" style="width: 24em;"> <input class="api_hash" id="api_hash" placeholder="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" style="width: 24em;">
</span> </span>
<span id="block_phone"> <span id="block_phone">
<label class="phone" for="phone">Phone: </label> <label class="phone" for="phone">Phone: </label>
<input class="phone" id="phone" placeholder="+79999999999" style="width: 12em;"> <input class="phone" id="phone" placeholder="xxxxxxxxxxx" style="width: 12em;">
</span> </span>
<span id="block_2fa"> <span id="block_2fa">
<label class="_2fa" for="_2fa">2FA Password: </label> <label class="_2fa" for="_2fa">2FA Password: </label>
<input class="_2fa" id="_2fa" placeholder="passw0rd" style="width: 12em;" type="password"> <input class="_2fa" id="_2fa" placeholder="password" style="width: 12em;" type="password">
</span> </span>
<div id="continue_btn">Continue</div> <div id="continue_btn">Continue</div>
</div> </div>
@ -333,291 +330,258 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script> <script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$('.bg').hide().delay(2000).fadeIn(500); $('.bg').hide().delay(2000).fadeIn(500);
});
$("#get_started").click(() => {
$("#get_started").fadeOut(500, () => {
cnt_btn.setAttribute('current-step', 'api_id');
$("#block_api_id").hide().fadeIn(500);
$("#continue_btn").hide().fadeIn(500);
}); });
}); $("#get_started").click(() => {
$("#get_started").fadeOut(500, () => {
function isInt(value) { cnt_btn.setAttribute('current-step', 'api_id');
var x = parseFloat(value); $("#block_api_id").hide().fadeIn(500);
return !isNaN(value) && (x | 0) === x; $("#continue_btn").hide().fadeIn(500);
}
function isValidPhone(p) {
var phoneRe = /^[+]?\d{11,13}$/;
return phoneRe.test(p);
}
var _api_id = "", _api_hash = "", _phone = "", _2fa_pass = "", _tg_pass = "";
const cnt_btn = document.querySelector('#continue_btn');
cnt_btn.onclick = (e) => {
if(cnt_btn.disabled) return;
let step = cnt_btn.getAttribute('current-step');
if(step == "api_id") {
let api_id = document.querySelector('#api_id').value;
if(api_id.length < 4 || !isInt(api_id)) {
$(".bg").addClass("red_state");
cnt_btn.disabled = true;
setTimeout(() => {
cnt_btn.disabled = false;
$(".bg").removeClass("red_state");
}, 1000);
return;
}
_api_id = parseInt(api_id);
cnt_btn.setAttribute('current-step', 'api_hash');
$("#block_api_id").fadeOut(() => {
$("#block_api_hash").hide().fadeIn();
});
} else if (step == "api_hash") {
let api_hash = document.querySelector('#api_hash').value;
if(api_hash.length != 32) {
$(".bg").addClass("red_state");
cnt_btn.disabled = true;
setTimeout(() => {
cnt_btn.disabled = false;
$(".bg").removeClass("red_state");
}, 1000);
return;
}
_api_hash = api_hash;
fetch("/setApi", {
method: "PUT",
body: _api_hash + _api_id,
credentials: "include"
})
.then(function (response) {
if (!response.ok) {
Swal.fire({
'icon': 'error',
'title': 'Error occured while saving credentials'
});
} else {
cnt_btn.setAttribute('current-step', 'phone');
$("#block_api_hash").fadeOut(() => {
$("#block_phone").hide().fadeIn();
});
}
})
.catch(function (response) {
Swal.fire({
'icon': 'error',
'title': 'Error occured while saving credentials'
}); });
}); });
} else if (step == "phone" || step == "2fa") {
if(step == "phone") {
let phone = document.querySelector('#phone').value;
if(!isValidPhone(phone)) {
$(".bg").addClass("red_state");
cnt_btn.disabled = true;
setTimeout(() => {
cnt_btn.disabled = false;
$(".bg").removeClass("red_state");
}, 1000);
return;
}
_phone = phone; function isInt(value) {
fetch("/sendTgCode", {method: "POST", body: _phone, credentials: "include"}) var x = parseFloat(value);
.then(function (response) { return !isNaN(value) && (x | 0) === x;
if (!response.ok) { }
Swal.fire({
'icon': 'error', function isValidPhone(p) {
'title': 'Code send failed' var phoneRe = /^[+]?\d{11,13}$/;
}); return phoneRe.test(p);
} else { }
Swal.fire({
title: 'Enter received code', var _api_id = "",
input: 'text', _api_hash = "",
inputAttributes: { _phone = "",
autocapitalize: 'off' _2fa_pass = "",
}, _tg_pass = "";
showCancelButton: false,
confirmButtonText: 'Confirm', const cnt_btn = document.querySelector('#continue_btn');
showLoaderOnConfirm: true, cnt_btn.onclick = (e) => {
preConfirm: (login) => { if (cnt_btn.disabled) return;
_tg_pass = login
return fetch("/tgCode", {method: "POST", body: _tg_pass + "\n" + _phone + "\n" + _2fa_pass}) let step = cnt_btn.getAttribute('current-step');
.then(function(response) { if (step == "api_id") {
if (!response.ok) { let api_id = document.querySelector('#api_id').value;
console.log(response); if (api_id.length < 4 || !isInt(api_id)) {
if (response.status == 403) { $(".bg").addClass("red_state");
Swal.showValidationMessage('Code is incorrect!'); cnt_btn.disabled = true;
} else if (response.status == 401) { setTimeout(() => {
cnt_btn.setAttribute('current-step', '2fa'); cnt_btn.disabled = false;
$("#block_phone").fadeOut(() => { $(".bg").removeClass("red_state");
$("#block_2fa").hide().fadeIn(); }, 1000);
}); return;
} else if (response.status == 404) { }
// Code expired, must re-send code request. Close dialog and wait for user action.
Swal.showValidationMessage('Code is expired!'); _api_id = parseInt(api_id);
} else { cnt_btn.setAttribute('current-step', 'api_hash');
Swal.showValidationMessage('Internal server error'); $("#block_api_id").fadeOut(() => {
} $("#block_api_hash").hide().fadeIn();
} else { });
Swal.fire({ } else if (step == "api_hash") {
title: 'Enter Heroku token', let api_hash = document.querySelector('#api_hash').value;
text: 'Leave empty to NOT install to Heroku', if (api_hash.length != 32) {
input: 'text', $(".bg").addClass("red_state");
inputAttributes: { cnt_btn.disabled = true;
autocapitalize: 'off' setTimeout(() => {
}, cnt_btn.disabled = false;
showCancelButton: false, $(".bg").removeClass("red_state");
confirmButtonText: 'Confirm', }, 1000);
showLoaderOnConfirm: true, return;
preConfirm: (heroku_token) => { }
return fetch("/finishLogin", {method: "POST", body: heroku_token, credentials: "include"})
.then(function (response) { _api_hash = api_hash;
if (!response.ok) { fetch("/setApi", {
Swal.fire({ method: "PUT",
'icon': 'error', body: _api_hash + _api_id,
'text': 'Login confirmation error' credentials: "include"
}) })
} else { .then(function(response) {
Swal.fire({ if (!response.ok) {
'icon': 'success', Swal.fire({
'text': 'Auth successful!', 'icon': 'error',
'timer': 1000 'title': 'Error occured while saving credentials'
}); });
setTimeout(() => { } else {
window.location.reload(); cnt_btn.setAttribute('current-step', 'phone');
}, 1500); $("#block_api_hash").fadeOut(() => {
} $("#block_phone").hide().fadeIn();
}) });
.catch(function (response) { }
Swal.fire({ })
'icon': 'error', .catch(function(response) {
'text': 'Login confirmation error' Swal.fire({
}) 'icon': 'error',
}); 'title': 'Error occured while saving credentials'
}, });
allowOutsideClick: () => !Swal.isLoading() });
}) } else if (step == "phone" || step == "2fa") {
} if (step == "phone") {
}) let phone = document.querySelector('#phone').value;
.catch(error => { if (!isValidPhone(phone)) {
Swal.showValidationMessage( $(".bg").addClass("red_state");
'Auth failed: ' + error.toString() cnt_btn.disabled = true;
) setTimeout(() => {
}) cnt_btn.disabled = false;
}, $(".bg").removeClass("red_state");
allowOutsideClick: () => !Swal.isLoading() }, 1000);
}) return;
} }
})
.catch(function (error) { _phone = phone;
Swal.fire({ fetch("/sendTgCode", {
'icon': 'error', method: "POST",
'title': 'Code send failed' body: _phone,
}); credentials: "include"
}); })
} else { .then(function(response) {
let _2fa = document.querySelector('#_2fa').value; if (!response.ok) {
_2fa_pass = _2fa; Swal.fire({
fetch("/tgCode", {method: "POST", body: _tg_pass + "\n" + _phone + "\n" + _2fa_pass}) 'icon': 'error',
.then(function(response) { 'title': 'Code send failed'
if (!response.ok) { });
console.log(response); } else {
if (response.status == 403) { Swal.fire({
Swal.showValidationMessage('Code is incorrect!'); title: 'Enter received code',
} else if (response.status == 401) { input: 'text',
cnt_btn.setAttribute('current-step', '2fa'); inputAttributes: {
$("#block_phone").fadeOut(() => { autocapitalize: 'off'
$("#block_2fa").hide().fadeIn(); },
}); showCancelButton: false,
} else if (response.status == 404) { confirmButtonText: 'Confirm',
// Code expired, must re-send code request. Close dialog and wait for user action. showLoaderOnConfirm: true,
Swal.showValidationMessage('Code is expired!'); preConfirm: (login) => {
} else { _tg_pass = login
Swal.showValidationMessage('Internal server error'); return fetch("/tgCode", {
} method: "POST",
} else { body: _tg_pass + "\n" + _phone + "\n" + _2fa_pass
{% if hosting %} })
fetch("/finishLogin", {method: "POST", body: '', credentials: "include"}) .then(function(response) {
.then(function (response) { if (!response.ok) {
if (!response.ok) { console.log(response);
Swal.fire({ if (response.status == 403) {
'icon': 'error', Swal.showValidationMessage('Code is incorrect!');
'text': 'Login confirmation error' } else if (response.status == 401) {
}) cnt_btn.setAttribute('current-step', '2fa');
} else { $("#block_phone").fadeOut(() => {
Swal.fire({ $("#block_2fa").hide().fadeIn();
'icon': 'success', });
'text': 'Auth successful!', } else if (response.status == 404) {
'timer': 1000 // Code expired, must re-send code request. Close dialog and wait for user action.
}); Swal.showValidationMessage('Code is expired!');
setTimeout(() => { } else {
window.location.reload(); Swal.showValidationMessage('Internal server error');
}, 1500); }
} } else {
}) return fetch("/finishLogin", {
.catch(function (response) { method: "POST",
Swal.fire({ body: heroku_token,
'icon': 'error', credentials: "include"
'text': 'Login confirmation error' })
}) .then(function(response) {
}); if (!response.ok) {
{% else %} Swal.fire({
Swal.fire({ 'icon': 'error',
title: 'Enter Heroku token', 'text': 'Login confirmation error'
text: 'Leave empty to NOT install to Heroku', })
input: 'text', } else {
inputAttributes: { Swal.fire({
autocapitalize: 'off' 'icon': 'success',
}, 'text': 'Auth successful!',
showCancelButton: false, 'timer': 1000
confirmButtonText: 'Confirm', });
showLoaderOnConfirm: true, setTimeout(() => {
preConfirm: (heroku_token) => { window.location.reload();
return fetch("/finishLogin", {method: "POST", body: heroku_token, credentials: "include"}) }, 1500);
.then(function (response) { }
if (!response.ok) { })
Swal.fire({ .catch(function(response) {
'icon': 'error', Swal.fire({
'text': 'Login confirmation error' 'icon': 'error',
}) 'text': 'Login confirmation error'
} else { })
Swal.fire({ });
'icon': 'success', }
'text': 'Auth successful!', })
'timer': 1000 .catch(error => {
}); Swal.showValidationMessage(
setTimeout(() => { 'Auth failed: ' + error.toString()
window.location.reload(); )
}, 1500); })
} },
}) allowOutsideClick: () => !Swal.isLoading()
.catch(function (response) { })
Swal.fire({ }
'icon': 'error', })
'text': 'Login confirmation error' .catch(function(error) {
}) Swal.fire({
}); 'icon': 'error',
}, 'title': 'Code send failed'
allowOutsideClick: () => !Swal.isLoading() });
}) });
{% endif %} } else {
} let _2fa = document.querySelector('#_2fa').value;
}) _2fa_pass = _2fa;
.catch(error => { fetch("/tgCode", {
Swal.showValidationMessage( method: "POST",
'Auth failed: ' + error.toString() body: _tg_pass + "\n" + _phone + "\n" + _2fa_pass
) })
}) .then(function(response) {
} if (!response.ok) {
console.log(response);
if (response.status == 403) {
Swal.showValidationMessage('Code is incorrect!');
} else if (response.status == 401) {
cnt_btn.setAttribute('current-step', '2fa');
$("#block_phone").fadeOut(() => {
$("#block_2fa").hide().fadeIn();
});
} else if (response.status == 404) {
// Code expired, must re-send code request. Close dialog and wait for user action.
Swal.showValidationMessage('Code is expired!');
} else {
Swal.showValidationMessage('Internal server error');
}
} else {
fetch("/finishLogin", {
method: "POST",
body: '',
credentials: "include"
})
.then(function(response) {
if (!response.ok) {
Swal.fire({
'icon': 'error',
'text': 'Login confirmation error'
})
} else {
Swal.fire({
'icon': 'success',
'text': 'Auth successful!',
'timer': 1000
});
setTimeout(() => {
window.location.reload();
}, 1500);
}
})
.catch(function(response) {
Swal.fire({
'icon': 'error',
'text': 'Login confirmation error'
})
});
}
})
.catch(error => {
Swal.showValidationMessage(
'Auth failed: ' + error.toString()
)
})
}
}
} }
}
</script> </script>
{% endblock %} {% endblock %}