-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
82 changed files
with
2,538 additions
and
1,104 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ npm-debug.log | |
|
||
.vscode/launch.json | ||
.idea | ||
|
||
client/npm-debug.log.1734035463 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
preset: laravel | ||
|
||
finder: | ||
exclude: | ||
- tests | ||
- views | ||
|
||
not-name: | ||
- index.php | ||
- server.php | ||
- AuthServiceProvider.php |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
language: php | ||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
|
||
# This triggers builds to run on the new TravisCI infrastructure. | ||
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/ | ||
sudo: false | ||
|
||
## Cache composer for faster builds | ||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
||
before_script: | ||
- cd ./webservice | ||
- cp .env.travis .env | ||
- travis_retry composer self-update | ||
- travis_retry composer update --no-interaction --prefer-dist | ||
- php artisan key:gen | ||
- php artisan jwt:secret -f | ||
|
||
script: | ||
- vendor/bin/phpunit |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module.exports = { | ||
NODE_ENV: '"production"', | ||
API_URL: '"https://spa.vedcasts.com.br/api"', | ||
VERSION: '"1.0.2"', | ||
VERSION: '"1.0.3"', | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "codecasts-spa-starter-kit", | ||
"version": "1.0.0", | ||
"version": "1.0.3", | ||
"description": "Client for Codecast's SPA Starter Kit", | ||
"author": "Fabio Vedovelli <[email protected]>", | ||
"private": true, | ||
|
@@ -15,13 +15,15 @@ | |
"dependencies": { | ||
"axios": "^0.15.2", | ||
"bootstrap-sass": "^3.3.7", | ||
"element-ui": "^1.0.7", | ||
"font-awesome": "^4.7.0", | ||
"jquery": "^3.1.1", | ||
"lodash": "^4.17.2", | ||
"sweetalert": "^1.1.3", | ||
"vue": "^2.0.1", | ||
"vue-router": "^2.0.1", | ||
"vuex": "^2.0.0" | ||
"vuex": "^2.0.0", | ||
"vuex-router-sync": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"autoprefixer": "^6.4.0", | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<script> | ||
import { mapActions } from 'vuex' | ||
export default { | ||
/** | ||
* Component's local state | ||
*/ | ||
data() { | ||
return { | ||
email: '[email protected]', | ||
password: '123456', | ||
} | ||
}, | ||
methods: { | ||
/** | ||
* Map the actions from Vuex to this component. | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator | ||
*/ | ||
...mapActions(['attemptLogin', 'setMessage']), | ||
/** | ||
* Handle form's submit event | ||
*/ | ||
submit() { | ||
const { email, password } = this // http://wesbos.com/destructuring-objects/ | ||
this.attemptLogin({ email, password }) // this is a Vuex action | ||
.then(() => { | ||
this.setMessage({ type: 'error', message: [] }) // this is a Vuex action | ||
this.$router.push({ name: 'dashboard.index' }) | ||
}) | ||
}, | ||
/** | ||
* Reset component's local state | ||
*/ | ||
reset() { | ||
this.email = '' | ||
this.password = '' | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<template> | ||
<form class="well" @submit.prevent="submit"> | ||
<div class="form-group"> | ||
<label for="email" class="control-label">E-mail</label> | ||
<input type="email" class="form-control" id="email" v-model="email"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="password" class="control-label">Password</label> | ||
<input type="password" class="form-control" id="password" v-model="password"> | ||
</div> | ||
<button class="btn btn-primary btn-block" type="submit">Login</button> | ||
</form> | ||
</template> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<template> | ||
<div class="well"> | ||
<h3>Sing up</h3> | ||
<h4>Comming soon</h4> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
} | ||
</script> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<template> | ||
<div class="container"> | ||
<header class="page-header"> | ||
<h3>Codecasts - SPA - Starter Kit</h3> | ||
</header> | ||
<div class="row"> | ||
<div class="col-md-2"></div> | ||
<div class="col-md-3"> | ||
<ul class="nav nav-pills nav-stacked"> | ||
<router-link tag="li" :to="{ name: 'auth.singin' }"> | ||
<a>Sing in</a> | ||
</router-link> | ||
<router-link tag="li" :to="{ name: 'auth.singup' }"> | ||
<a>Sing up</a> | ||
</router-link> | ||
</ul> | ||
</div> | ||
<div class="col-md-4"> | ||
<router-view></router-view> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
} | ||
</script> | ||
|
||
<style lang="css"> | ||
</style> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export | ||
export { default as routes } from './routes' | ||
export { default as vuex } from './vuex' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Components are lazy-loaded - See "Grouping Components in the Same Chunk" | ||
* http://router.vuejs.org/en/advanced/lazy-loading.html | ||
*/ | ||
/* eslint-disable global-require */ | ||
export const Main = r => require.ensure([], () => r(require('../components/main')), 'auth-bundle') | ||
export const Singin = r => require.ensure([], () => r(require('../components/forms/singin')), 'auth-bundle') | ||
export const Singup = r => require.ensure([], () => r(require('../components/forms/singup')), 'auth-bundle') |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Singup, Singin, Main } from './components' | ||
|
||
const children = [{ | ||
name: 'auth.singin', | ||
path: 'singin', | ||
component: Singin, | ||
meta: { requiresAuth: false }, | ||
}, { | ||
name: 'auth.singup', | ||
path: 'singup', | ||
component: Singup, | ||
meta: { requiresAuth: false }, | ||
}] | ||
|
||
export default [{ | ||
children, | ||
name: 'auth', | ||
path: '/auth', | ||
component: Main, | ||
redirect: { name: 'auth.singin' }, | ||
meta: { requiresAuth: false }, | ||
}] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// plugins and utils are alias. see client/build/webpack.base.conf.js | ||
// import http client | ||
import { http, setToken as httpSetToken } from 'plugins/http' | ||
import { isEmpty } from 'lodash' | ||
import { getData } from 'utils/get' | ||
import * as TYPES from './mutations-types' | ||
|
||
export const attemptLogin = ({ dispatch }, { email, password }) => http.post('/auth/token/issue', { email, password }) | ||
/** | ||
* functional approach, more readable and generate minus code | ||
* examples: | ||
* PromiseObject.then(response => response.data) | ||
* PromiseObject.then({ data } => data) | ||
* | ||
* We do this many times in many locations. | ||
* We know that .then accepts a function and what arguments it receives | ||
* This is because in JavaScript functions are first class citizens. | ||
* In summary we can pass functions as arguments and also receive functions as results | ||
* (first-class function and higher-order function) | ||
*/ | ||
.then(getData) // .then(response => getData(response)) | ||
.then(({ token, user }) => { | ||
dispatch('setUser', user) | ||
dispatch('setToken', token) | ||
|
||
return user // keep promise chain | ||
}) | ||
|
||
export const logout = ({ dispatch }) => { | ||
http.post('/auth/token/revoke') | ||
// call actions | ||
return Promise.all([ | ||
dispatch('setToken', null), | ||
dispatch('setUser', {}), | ||
]) | ||
} | ||
|
||
export const setUser = ({ commit }, user) => { | ||
// Commit the mutations | ||
commit(TYPES.SET_USER, user) | ||
|
||
Promise.resolve(user) // keep promise chain | ||
} | ||
|
||
export const setToken = ({ commit }, payload) => { | ||
// prevent if payload is a object | ||
const token = (isEmpty(payload)) ? null : payload.token || payload | ||
|
||
/** | ||
* Set the Axios Authorization header with the token | ||
*/ | ||
httpSetToken(token) | ||
|
||
// Commit the mutations | ||
commit(TYPES.SET_TOKEN, token) | ||
|
||
return Promise.resolve(token) // keep promise chain | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// http://vuex.vuejs.org/en/getters.html | ||
import { isEmpty } from 'lodash' | ||
|
||
// if has token, we assume that user is logged in our system | ||
export const isLogged = ({ token }) => !isEmpty(token) | ||
// get current user data | ||
export const currentUser = ({ user }) => user |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import | ||
import state from './state' | ||
import mutations from './mutations' | ||
import plugin from './plugin' | ||
import * as actions from './actions' | ||
import * as getters from './getters' | ||
|
||
const module = { state, mutations, actions, getters } | ||
|
||
export default { module, plugin } |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// http://vuex.vuejs.org/en/mutations.html#using-constants-for-mutation-types | ||
export const SET_TOKEN = 'Auth//SET_TOKEN' | ||
export const SET_USER = 'Auth//SET_USER' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// https://vuex.vuejs.org/en/mutations.html | ||
import * as TYPES from './mutations-types' | ||
|
||
/* eslint-disable no-param-reassign */ | ||
export default { | ||
[TYPES.SET_TOKEN](state, value) { | ||
state.token = value | ||
}, | ||
[TYPES.SET_USER](state, value) { | ||
state.user = value | ||
}, | ||
} |
Oops, something went wrong.