Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Trying to focus

Farhan Hasin Chowdhury fhsinchy

🎯
Trying to focus
View GitHub Profile
View notes-api-docker-compose.yaml
## /notes-api/docker-compose.yaml
version: "3.8"
services:
db:
image: postgres:12
volumes:
- db-data:/var/lib/postgresql/data
environment:
View guide-to-laravel-passport-interceptor-main.js
// src/main.js
// ...
import configureAxios from './services/http';
//...
configureAxios();
View guide-to-laravel-passport-http.js
// services/http.js
import axios from 'axios';
import router from '@/router';
import { store, mutations, actions } from '@/store';
export default function configureAxios() {
axios.defaults.headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
View guide-to-laravel-passport-token-lifetime.php
<?php
namespace App\Providers;
// ...
class AuthServiceProvider extends ServiceProvider
{
// ...
View guide-to-laravel-passport-app-logout.vue
// src/App.vue
<script>
import { actions } from '@/store';
export default {
// ...
methods: {
// ...
logout() {
View guide-to-laravel-passport-app-store-logout.js
// src/store.js
// ...
export const actions = {
logout() {
store.accessToken = null;
window.localStorage.removeItem('accessToken');
window.localStorage.removeItem('refreshToken');
},
View guide-to-laravel-passport-home-user.vue
// src/views/Home.vue
<script>
import axios from 'axios';
import { store, getters } from '@/store';
export default {
async mounted() {
if (this.isLoggedIn) {
try {
View guide-to-laravel-passport-home-app-isloggedin.vue
// src/App.vue
// src/views/Home.vue
<script>
// ...
import { getters } from '@/store';
export default {
computed: {
isLoggedIn: () => getters.isLoggedIn(),
View guide-to-laravel-passport-callback-mounted-store.vue
// src/views/OAuthCallbackHandler.vue
<script>
import axios from 'axios';
import { mutations } from '@/store';
export default {
async mounted() {
try {
const response = await axios.post('/oauth/token', {
View guide-to-laravel-passport-store.js
// src/store.js
import Vue from 'vue';
export const store = Vue.observable({
accessToken: window.localStorage.getItem('accessToken'),
});
export const getters = {
isLoggedIn() {