Skip to content

Commit 6f0f14e

Browse files
committed
🚧 Validate JWT in platform/courses
1 parent c42195a commit 6f0f14e

File tree

8 files changed

+52
-31
lines changed

8 files changed

+52
-31
lines changed

.eslintrc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"parserOptions": {
44
"sourceType": "module"
55
},
6-
"plugins": ["prettier", "svelte3"],
7-
"extends": ["prettier"],
8-
"rules": {
9-
"prettier/prettier": "error"
10-
}
11-
}
6+
"plugins": [
7+
"svelte3"
8+
],
9+
"extends": [],
10+
"rules": {}
11+
}

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"editor.formatOnSave": true,
3+
"eslint.autoFixOnSave": true,
34
"files.associations": {
45
".huskyrc": "json",
56
".lintstagedrc": "json"
67
}
7-
}
8+
}

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
import { start, goto, prefetch, prefetchRoutes } from '@sapper/app'
2-
import UserService from './services/user.service'
32

43
start({
54
target: document.querySelector('#sapper'),
6-
}).then(async function() {
7-
const { status } = await UserService.validate()
8-
9-
console.log(status)
10-
11-
// status !== 200 && goto('login')
12-
})
13-
14-
prefetch('platform/profile').then(() => {
15-
console.log('PREFETCH')
165
})
176

18-
prefetchRoutes().then(() => console.log('PREFETCH ROUTES'))

src/containers/FormLogin.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
}
1313
1414
async function login() {
15-
const res = await UserService.login(user)
16-
1715
const {
1816
status,
1917
data: { field, error },
20-
} = res
18+
} = await UserService.login(user)
2119
2220
if (status === 200) {
2321
goto('platform/courses')

src/containers/MenuMobile.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
<ul class="list">
3434
{#each menu as { href, label, icon }}
3535
<li class="option">
36-
<a {href} class={`action ${segment === icon ? '-selected' : ''}`}>
36+
<a
37+
{href}
38+
rel="prefetch"
39+
class={`action ${segment === icon ? '-selected' : ''}`}>
3740
<IconCollab
3841
alt={`Página de ${label}`}
3942
name={icon && icon === segment ? `${icon}-selected` : icon} />

src/routes/platform/_layout.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script>
2+
import { onMount } from 'svelte'
23
import HeaderCollab from '../../containers/HeaderCollab.svelte'
34
import MenuMobile from '../../containers/MenuMobile.svelte'
45

src/routes/platform/courses.svelte

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
1+
<script context="module">
2+
import UserService from '../../services/user.service'
3+
4+
export async function preload() {}
5+
</script>
6+
17
<script>
8+
import { goto } from '@sapper/app'
9+
import { onMount } from 'svelte'
210
import TitleCollab from '../../components/TitleCollab.svelte'
11+
12+
let showStatus
13+
14+
onMount(async () => {
15+
try {
16+
const { status, data } = await UserService.validate()
17+
18+
console.log('ENTRO!!!')
19+
20+
if (status !== 200) {
21+
goto('login')
22+
23+
return false
24+
}
25+
26+
showStatus = status
27+
} catch (error) {
28+
goto('login')
29+
}
30+
})
331
</script>
432

5-
<TitleCollab content="Um dia serei a página de Cursos" />
33+
{#if showStatus === 200}
34+
<TitleCollab content="Um dia serei a página de Cursos" />
35+
{/if}

0 commit comments

Comments
 (0)