Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- var vue = new Vue({
- el: '#login',
- data: {
- logged_in: false,
- username: "",
- password: "",
- csrf_token: "",
- },
- methods: {
- login: function() {
- $.ajax({
- url: apiEndpoint + '/login/',
- type: "POST",
- dataType: "json",
- dataType: 'json',
- data: JSON.stringify({"username": username.value,
- "password": password.value,
- "csrf_token": this.csrf_token}),
- success: (data) => {
- alert(1);
- }
- });
- return false;
- },
- getCsrfToken: function() {
- $.ajax({
- url: apiEndpoint + '/login/',
- success: (data) => {
- this.csrf_token = data["Csrf_Token"];
- if(data["User_id"] !== "") {
- this.logged_in = true;
- }
- }
- });
- }
- }
- });
- vue.getCsrfToken();
- });
- w.Header().Set("Access-Control-Allow-Origin", "*")
- w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
- w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS")
- fmt.Printf("METHOD - %sn", r.Method)
- if r.Method == "POST" {
- appmux := http.NewServeMux()
- appmux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("../www/static"))))
- appmux.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("../www/assets"))))
- appmux.Handle("/login/", commonMiddlewares(http.HandlerFunc(loginHandler)))
- appmux.Handle("/logout/", secure(http.HandlerFunc(logoutHandler)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement