This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="container"> | |
<header class="jumbotron"> | |
<h3>{{content}}</h3> | |
</header> | |
</div> | |
</template> | |
<script> | |
import UserService from '../services/user.service'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="container"> | |
<header class="jumbotron"> | |
<h3>Profile</h3> | |
<h3> | |
<strong>{{currentUser.username}}</strong> | |
</h3> | |
<p> | |
<strong>Id:</strong> | |
{{currentUser.id}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="col-md-12"> | |
<div class="card card-container"> | |
<img | |
id="profile-img" | |
src="//ssl.gstatic.com/accounts/ui/avatar_2x.png" | |
class="profile-img-card" | |
/> | |
<form name="form" @submit.prevent="handleLogin"> | |
<div class="form-group"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="col-md-12"> | |
<div class="card card-container"> | |
<img | |
id="profile-img" | |
src="//ssl.gstatic.com/accounts/ui/avatar_2x.png" | |
class="profile-img-card" | |
/> | |
<form name="form" @submit.prevent="handleRegister"> | |
<div v-if="!successful"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class User { | |
constructor(username, email, password) { | |
this.username = username; | |
this.email = email; | |
this.password = password; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AuthService from '../services/auth.service'; | |
const user = JSON.parse(localStorage.getItem('user')); | |
const initialState = user | |
? { status: { loggedIn: true }, user } | |
: { status: { loggedIn: false }, user: null }; | |
export const auth = { | |
namespaced: true, | |
state: initialState, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue'; | |
import Vuex from 'vuex'; | |
import { auth } from './auth.module'; | |
Vue.use(Vuex); | |
export default new Vuex.Store({ | |
modules: { | |
auth |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
// for Lumen 7 back-end | |
const API_URL = 'http://localhost:8000/api/test/'; | |
// for Node.js back-end | |
// const API_URL = 'http://localhost:9090/api/test/'; | |
class UserService { | |
getPublicContent() { | |
return axios.get(API_URL + 'all'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function authHeader() { | |
let user = JSON.parse(localStorage.getItem('user')); | |
if (user && user.accessToken) { | |
// for Lumen 7 back-end | |
return { Authorization: 'Bearer ' + user.accessToken }; | |
// for Node.js Express back-end | |
// return { 'x-access-token': user.accessToken }; | |
} else { | |
return {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
// for Lumen 7 back-end | |
const API_URL = 'http://localhost:8000/api/auth/'; | |
// for Node.js back-end | |
// const API_URL = 'http://localhost:9090/api/auth/'; | |
class AuthService { | |
login(user) { | |
return axios |