@@ -79,4 +79,8 @@ class UserController extends Controller | |||||
return redirect('/'); | return redirect('/'); | ||||
} | } | ||||
public function getOrders(Request $request) { | |||||
} | |||||
} | } |
@@ -26,9 +26,18 @@ class DatabaseSeeder extends Seeder | |||||
'name' => 'test_user_verified', | 'name' => 'test_user_verified', | ||||
'email' => 'verified@example.com', | 'email' => 'verified@example.com', | ||||
'email_verified_at' => now(), | 'email_verified_at' => now(), | ||||
'credits' => 250, | |||||
'role' => 'client', | 'role' => 'client', | ||||
'active' => true, | 'active' => true, | ||||
'password' => Hash::make("test123") | 'password' => Hash::make("test123") | ||||
]); | ]); | ||||
User::create([ | |||||
'name' => 'test_admin_verified', | |||||
'email' => 'admin_verified@example.com', | |||||
'email_verified_at' => now(), | |||||
'role' => 'admin', | |||||
'active' => true, | |||||
'password' => Hash::make("test123") | |||||
]); | |||||
} | } | ||||
} | } |
@@ -50,6 +50,34 @@ function login(event) { | |||||
event.stopPropogation() | event.stopPropogation() | ||||
} | } | ||||
function getUser(app) { | |||||
fetch("/panel/user", { | |||||
method: 'GET', | |||||
headers: {'Content-Type': 'application/json', | |||||
'Accept': 'application/json', | |||||
'X-XSRF-TOKEN': token}, | |||||
}).then(response => { | |||||
return response.json() | |||||
}).then(data => { | |||||
app.user = data | |||||
}) | |||||
/* return this.user.name */ | |||||
} | |||||
function getOrders(app) { | |||||
fetch("/panel/orders", { | |||||
method: 'GET', | |||||
headers: {'Content-Type': 'application/json', | |||||
'Accept': 'application/json', | |||||
'X-XSRF-TOKEN': token}, | |||||
}).then(response => { | |||||
return response.json() | |||||
}).then(data => { | |||||
app.orders = data | |||||
}) | |||||
/* return this.user.name */ | |||||
} | |||||
//Attempt to resend the verification link | //Attempt to resend the verification link | ||||
function resendLink(event) { | function resendLink(event) { | ||||
fetch("/resend-verification", { | fetch("/resend-verification", { | ||||
@@ -113,5 +141,6 @@ if (window.location.pathname == '/') { | |||||
if (!token) {getToken(app)} | if (!token) {getToken(app)} | ||||
const app = createApp(Panel).mount('#panel') | const app = createApp(Panel).mount('#panel') | ||||
window.onhashchange = ()=>{app.active = location.hash} | window.onhashchange = ()=>{app.active = location.hash} | ||||
getUser(app) | |||||
} | } | ||||
@@ -2,8 +2,8 @@ | |||||
<sidebar :active="active"></sidebar> | <sidebar :active="active"></sidebar> | ||||
<transition name="fade" mode="out-in"> | <transition name="fade" mode="out-in"> | ||||
<div v-if="active === ''" id="main"> | <div v-if="active === ''" id="main"> | ||||
<section class="welcome-pane"><h3>Welcome, user!</h3></section> | <section class="welcome-pane"><h3>Welcome, {{user.name}}!</h3></section> | ||||
<section class="credits-pane"><img src="../../images/wallet2.svg" alt="wallet" class="icon"/><p>Credits: ${{credits}}</p></section> | <section class="credits-pane"><img src="../../images/wallet2.svg" alt="wallet" class="icon"/><p>Credits: ${{user.credits}}</p></section> | ||||
<section class="alerts-pane"><h4>News and Announcements</h4> | <section class="alerts-pane"><h4>News and Announcements</h4> | ||||
<p>We've just launched. Thanks for joining us.</p> | <p>We've just launched. Thanks for joining us.</p> | ||||
</section> | </section> | ||||
@@ -21,15 +21,12 @@ | |||||
<script> | <script> | ||||
import Sidebar from './sidebar.vue' | import Sidebar from './sidebar.vue' | ||||
/* let token = RegExp('XSRF-TOKEN=([^;]+)').exec(document.cookie) */ | |||||
/* console.log(token) */ | |||||
export default { | export default { | ||||
components: { | components: { | ||||
Sidebar, | Sidebar, | ||||
}, | }, | ||||
data() { | data() { | ||||
return {active: window.location.hash, credits: 0, } | return {active: window.location.hash, user: '', | ||||
}, | token: ''}}, | ||||
} | } | ||||
</script> | </script> |
@@ -57,4 +57,8 @@ Route::post('/login', [UserController::class, | |||||
Route::get('/panel/user', function (Request $request) { | Route::get('/panel/user', function (Request $request) { | ||||
return $request->user(); | return $request->user(); | ||||
}); | })->middleware('auth'); | ||||
Route::post('/panel/orders', [UserController::class, | |||||
'getOrders'])->middleware('auth'); | |||||