Progressing

This commit is contained in:
An Phan 2015-12-29 08:16:36 +07:00
parent 9637f4cd26
commit 92b81c7b5b
6 changed files with 340 additions and 22 deletions

View file

@ -5,7 +5,8 @@ Route::post('login', 'Auth\AuthController@postLogin');
Route::get('logout', 'Auth\AuthController@getLogout');
Route::get('/', function () {
return redirect('/♫');
//return redirect('/♫');
return view('index');
});
Route::get('♫', ['middleware' => 'auth', function () {

View file

@ -10,7 +10,8 @@
"james-heinrich/getid3": "^1.9",
"phanan/cascading-config": "~2.0",
"barryvdh/laravel-ide-helper": "^2.1",
"guzzlehttp/guzzle": "^6.1"
"guzzlehttp/guzzle": "^6.1",
"tymon/jwt-auth": "^0.5.6"
},
"require-dev": {
"fzaninotto/faker": "~1.4",

215
composer.lock generated
View file

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "8d7c920507469687a49621c7be0bf7e6",
"content-hash": "5df94e186a0a3f71bcd4e1229edb99b0",
"hash": "73595742c708c946629155b84a000a62",
"content-hash": "b4898021e96521543995ae80b2a17399",
"packages": [
{
"name": "barryvdh/laravel-ide-helper",
@ -910,6 +910,56 @@
],
"time": "2015-01-11 23:07:46"
},
{
"name": "namshi/jose",
"version": "5.0.2",
"source": {
"type": "git",
"url": "https://github.com/namshi/jose.git",
"reference": "8c7eba486f74c014ea1d8faedafe5109a31ea95b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/namshi/jose/zipball/8c7eba486f74c014ea1d8faedafe5109a31ea95b",
"reference": "8c7eba486f74c014ea1d8faedafe5109a31ea95b",
"shasum": ""
},
"require": {
"lib-openssl": "*",
"php": ">=5.3.3",
"phpseclib/phpseclib": "~0.3"
},
"require-dev": {
"phpunit/phpunit": "~4.5",
"satooshi/php-coveralls": "dev-master"
},
"type": "library",
"autoload": {
"psr-0": {
"Namshi\\JOSE": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alessandro Nadalin",
"email": "alessandro.nadalin@gmail.com"
}
],
"description": "JSON Object Signing and Encryption library for PHP.",
"keywords": [
"JSON Web Signature",
"JSON Web Token",
"JWS",
"json",
"jwt",
"token"
],
"time": "2015-06-29 05:41:44"
},
{
"name": "nesbot/carbon",
"version": "1.21.0",
@ -1153,6 +1203,104 @@
],
"time": "2015-02-03 12:10:50"
},
{
"name": "phpseclib/phpseclib",
"version": "0.3.10",
"source": {
"type": "git",
"url": "https://github.com/phpseclib/phpseclib.git",
"reference": "d15bba1edcc7c89e09cc74c5d961317a8b947bf4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/d15bba1edcc7c89e09cc74c5d961317a8b947bf4",
"reference": "d15bba1edcc7c89e09cc74c5d961317a8b947bf4",
"shasum": ""
},
"require": {
"php": ">=5.0.0"
},
"require-dev": {
"phing/phing": "~2.7",
"phpunit/phpunit": "~4.0",
"sami/sami": "~2.0",
"squizlabs/php_codesniffer": "~1.5"
},
"suggest": {
"ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
"ext-mcrypt": "Install the Mcrypt extension in order to speed up a wide variety of cryptographic operations.",
"pear-pear/PHP_Compat": "Install PHP_Compat to get phpseclib working on PHP < 4.3.3."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.3-dev"
}
},
"autoload": {
"psr-0": {
"Crypt": "phpseclib/",
"File": "phpseclib/",
"Math": "phpseclib/",
"Net": "phpseclib/",
"System": "phpseclib/"
},
"files": [
"phpseclib/Crypt/Random.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
"phpseclib/"
],
"license": [
"MIT"
],
"authors": [
{
"name": "Jim Wigginton",
"email": "terrafrost@php.net",
"role": "Lead Developer"
},
{
"name": "Patrick Monnerat",
"email": "pm@datasphere.ch",
"role": "Developer"
},
{
"name": "Andreas Fischer",
"email": "bantu@phpbb.com",
"role": "Developer"
},
{
"name": "Hans-Jürgen Petrich",
"email": "petrich@tronic-media.com",
"role": "Developer"
}
],
"description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
"homepage": "http://phpseclib.sourceforge.net",
"keywords": [
"BigInteger",
"aes",
"asn.1",
"asn1",
"blowfish",
"crypto",
"cryptography",
"encryption",
"rsa",
"security",
"sftp",
"signature",
"signing",
"ssh",
"twofish",
"x.509",
"x509"
],
"time": "2015-01-28 21:50:33"
},
{
"name": "psr/http-message",
"version": "1.0",
@ -2194,6 +2342,69 @@
],
"time": "2015-12-05 11:13:14"
},
{
"name": "tymon/jwt-auth",
"version": "0.5.6",
"source": {
"type": "git",
"url": "https://github.com/tymondesigns/jwt-auth.git",
"reference": "f70842d94a548f1457114dd57b6c0b9bf94ba13c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tymondesigns/jwt-auth/zipball/f70842d94a548f1457114dd57b6c0b9bf94ba13c",
"reference": "f70842d94a548f1457114dd57b6c0b9bf94ba13c",
"shasum": ""
},
"require": {
"illuminate/http": "~5.0",
"illuminate/support": "~5.0",
"namshi/jose": "5.0.*",
"nesbot/carbon": "~1.0",
"php": ">=5.4.0"
},
"require-dev": {
"illuminate/auth": "~5.0",
"illuminate/console": "~5.0",
"illuminate/database": "~5.0",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "4.*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-develop": "0.5-dev"
}
},
"autoload": {
"psr-4": {
"Tymon\\JWTAuth\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Sean Tymon",
"email": "tymon148@gmail.com",
"homepage": "http://tymondesigns.com",
"role": "Developer"
}
],
"description": "JSON Web Token Authentication for Laravel 4 and 5",
"homepage": "https://github.com/tymondesigns/jwt-auth",
"keywords": [
"Authentication",
"JSON Web Token",
"auth",
"jwt",
"laravel",
"tymon"
],
"time": "2015-11-24 20:02:19"
},
{
"name": "vlucas/phpdotenv",
"version": "v2.1.0",

View file

@ -1,5 +1,5 @@
<template>
<div id="app" tabindex="0"
<div id="app" tabindex="0" v-show="currentUser.id"
@keydown.space="togglePlayback"
@keydown.j = "playNext"
@keydown.k = "playPrev"
@ -13,6 +13,10 @@
<site-footer></site-footer>
<overlay :state.sync="overlayState"></overlay>
</div>
<div class="login-wrapper" v-else>
<login-form></login-form>
</div>
</template>
<script>
@ -22,19 +26,22 @@
import siteFooter from './components/site-footer/index.vue';
import mainWrapper from './components/main-wrapper/index.vue';
import overlay from './components/shared/overlay.vue';
import loginForm from './components/auth/login-form.vue';
import sharedStore from './stores/shared';
import preferenceStore from './stores/preference';
import playback from './services/playback';
import userStore from './stores/user';
export default {
components: { siteHeader, siteFooter, mainWrapper, overlay },
components: { siteHeader, siteFooter, mainWrapper, overlay, loginForm },
replace: false,
data() {
return {
prefs: preferenceStore.state,
currentUser: userStore.state.current,
overlayState: {
showing: true,
@ -46,24 +53,30 @@
},
ready() {
this.showOverlay();
// Make the most important HTTP request to get all necessary data from the server.
// Afterwards, init all mandatory stores and services.
sharedStore.init(() => {
playback.init(this);
this.hideOverlay();
// Ask for user's notificatio permission.
this.requestNotifPermission();
// Let all other compoenents know we're ready.
this.$broadcast('koel:ready');
});
if (this.currentUser.id) {
this.init();
}
},
methods: {
init() {
this.showOverlay();
// Make the most important HTTP request to get all necessary data from the server.
// Afterwards, init all mandatory stores and services.
sharedStore.init(() => {
playback.init(this);
this.hideOverlay();
// Ask for user's notificatio permission.
this.requestNotifPermission();
// Let all other compoenents know we're ready.
this.$broadcast('koel:ready');
});
},
/**
* Toggle playback when user presses Space key.
*
@ -223,7 +236,7 @@
@import "resources/assets/sass/partials/_mixins.scss";
@import "resources/assets/sass/partials/_shared.scss";
#app {
#app, .login-wrapper {
display: flex;
min-height: 100vh;
flex-direction: column;
@ -238,4 +251,8 @@
padding-bottom: $footerHeight;
}
.login-wrapper {
@include vertical-center();
}
</style>

View file

@ -0,0 +1,71 @@
<template>
<form @submit.prevent="login">
<input v-model="email" type="email" name="email" placeholder="Email Address" autofocus required>
<input v-model="password" type="password" name="password" placeholder="Password" required>
<button type="submit">Log In</button>
</form>
</template>
<script>
import userStore from '../../stores/user';
export default {
data() {
return {
email: '',
password: '',
};
},
methods: {
login() {
userStore.login(this.email, this.password, () => {
// Emit the event
});
},
},
};
</script>
<style lang="sass" scoped>
@import "resources/assets/sass/partials/_vars.scss";
@import "resources/assets/sass/partials/_mixins.scss";
@import "resources/assets/sass/partials/_shared.scss";
form {
width: 300px;
padding: 24px;
background: rgba(255,255,255,.08);
border-radius: 8px;
border: 1px solid #333;
}
form.error {
border-color: #8e4947;
}
form:before {
content: " ";
display: block;
background: url(/public/img/logo.svg) center top no-repeat;
background-size: 156px;
height: 172px;
}
input {
display: block;
margin-top: 12px;
padding: 8px;
border: 0;
background: #fff;
outline: none;
width: 100%;
border-radius: 3px;
}
button {
display: block;
margin-top: 12px;
width: 100%;
}
</style>

View file

@ -71,6 +71,23 @@ export default {
user.avatar = `https://www.gravatar.com/avatar/${md5(user.email)}?s=256`;
},
/**
* Log a user in.
*
* @param {String} email
* @param {String} password
* @param {Function} cb
*/
login(email, password, cb = null) {
http.post('me', { email, password }, user => {
this.current = user;
if (cb) {
cb();
}
});
},
/**
* Update the current user's profile.
*