Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- $(function() {
- $("#loginForm").submit(function(event) {
- $("#success").css("display", "block"), $('#success').html("Autenticando...");
- $('#info').hide();
- $('.form-group').hide();
- var rootUrl = "<?php echo URL_BASE; ?>";
- var username = $("#username").val();
- var password = $("#password").val();
- $.ajax( {
- method: "POST",
- url: "api/login.php",
- dataType: "JSON",
- data: $(this).serialize(),
- success: function(i) {
- if (i["status"] == "success") {
- $("#error").css("display", "none");
- location.href = rootUrl + "/options/?welcome=true";
- } else {
- if (i["status"] == "error") {
- $("#error").css("display", "block"), $("#error").html(i["message"]);
- $("#success").css("display", "none"), $("#success").empty();
- $(".form-group").show();
- $("#info").show();
- return false;
- }
- }
- }, error: function (error) { console.log(error); }
- });
- return false;
- });
- });
- </script>
- if (isset($cookies['auth_token'])) {
- Cookies::set('auth_token', $cookies['auth_token']);
- Cookies::set('user', $ttrUsername);
- Cookies::set('pass', $ttrPassword);
- $_SESSION[SITE_NAME . '_SESSION'] = $ttrUsername;
- echo json_encode(array(
- "status" => "success",
- "message" => "Autenticação bem sucedida, estamos te redirecionando.",
- ));
- } else {
- echo json_encode(
- array(
- "status" => "error",
- 'message'=> "Não foi possível autenticar com o Twitter.",
- ));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement