Done for Login and notification system

This commit is contained in:
Sam Liu 2024-05-30 14:35:48 +00:00
parent d5c967d2e5
commit 9400113a57
52 changed files with 2204 additions and 616 deletions

20
.vscode/settings.json vendored
View File

@ -1,10 +1,26 @@
{
"editor.codeActionsOnSave": {
"source.organizeImports": "always",
"source.fixAll": "always"
"source.fixAll": "always",
"source.fixAll.eslint": "explicit"
},
"editor.suggest.preview": true,
"editor.inlayHints.enabled": "offUnlessPressed",
"javascript.inlayHints.parameterNames.enabled": "all",
"editor.formatOnSaveMode": "modificationsIfAvailable",
"eslint.workingDirectories": ["./fuware-fe"],
"editor.insertSpaces": true,
"editor.tabSize": 2,
"python.analysis.autoImportCompletions": true
"python.analysis.autoImportCompletions": true,
"python.analysis.indexing": true,
"python.analysis.fixAll": ["source.unusedImports"],
"python.analysis.packageIndexDepths": [
{
"name": "fuware",
"depth": 3,
"includeAllSymbols": false
}
]
// "python.analysis.extraPaths": ["./fuware"],
// "python.autoComplete.extraPaths": ["./fuware"]
}

View File

@ -12,10 +12,6 @@ dotenv:
- .env
- .dev.env
tasks:
py:setupdb:
desc: runs it first for init db
cmds:
- poetry run python fuware/db/init_db.py
py:dev:
desc: runs the backend server
cmds:

View File

@ -1,8 +1,8 @@
"""Create User and Session Modal
"""create user table
Revision ID: 56750c50a8c3
Revision ID: 68d05d045e6e
Revises:
Create Date: 2024-05-13 12:36:10.095215
Create Date: 2024-05-24 04:12:25.599139
"""
from typing import Sequence, Union
@ -12,7 +12,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '56750c50a8c3'
revision: str = '68d05d045e6e'
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
@ -36,27 +36,11 @@ def upgrade() -> None:
op.create_index(op.f('ix_users_name'), 'users', ['name'], unique=False)
op.create_index(op.f('ix_users_password'), 'users', ['password'], unique=False)
op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
op.create_table('session_login',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('session', sa.String(), nullable=False),
sa.Column('user_id', sa.UUID(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_session_login_created_at'), 'session_login', ['created_at'], unique=False)
op.create_index(op.f('ix_session_login_session'), 'session_login', ['session'], unique=True)
op.create_index(op.f('ix_session_login_user_id'), 'session_login', ['user_id'], unique=True)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_session_login_user_id'), table_name='session_login')
op.drop_index(op.f('ix_session_login_session'), table_name='session_login')
op.drop_index(op.f('ix_session_login_created_at'), table_name='session_login')
op.drop_table('session_login')
op.drop_index(op.f('ix_users_username'), table_name='users')
op.drop_index(op.f('ix_users_password'), table_name='users')
op.drop_index(op.f('ix_users_name'), table_name='users')

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"
rel="stylesheet"
/>
<title>League of legend Skins</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.jsx"></script>
</body>
</html>

View File

@ -4,6 +4,10 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"
rel="stylesheet"
/>
<title>Vite + Solid</title>
</head>
<body>

View File

@ -1,15 +1,16 @@
{
"extends": "./jsconfig.paths.json",
"compilerOptions": {
"module": "ESNext",
"jsx": "preserve",
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "preserve",
"jsxImportSource": "solid-js",
"resolveJsonModule": true,
"isolatedModules": false,
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
}
}

View File

@ -12,7 +12,6 @@
"prettier": "prettier \"src/**/*.{js,jsx}\" --write"
},
"dependencies": {
"@hope-ui/solid": "^0.6.7",
"@solidjs/router": "^0.13.3",
"@stitches/core": "^1.2.8",
"@tabler/icons-solidjs": "^3.3.0",
@ -21,13 +20,18 @@
"solid-form-handler": "^1.2.3",
"solid-js": "^1.8.15",
"solid-styled-components": "^0.28.5",
"solid-toast": "^0.5.0",
"yup": "^1.4.0"
},
"devDependencies": {
"eslint": "^9.2.0",
"autoprefixer": "^10.4.19",
"daisyui": "^4.11.1",
"eslint": "^8.56.0",
"eslint-plugin-solid": "^0.14.0",
"lint-staged": "15.2.2",
"postcss": "^8.4.38",
"prettier": "3.2.5",
"tailwindcss": "^3.4.3",
"vite": "^5.2.0",
"vite-plugin-mkcert": "^1.17.5",
"vite-plugin-solid": "^2.10.2"

932
fuware-fe/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 KiB

View File

Before

Width:  |  Height:  |  Size: 349 KiB

After

Width:  |  Height:  |  Size: 349 KiB

View File

@ -1,14 +1,19 @@
import { HopeProvider, NotificationsProvider } from '@hope-ui/solid'
import { Toaster } from 'solid-toast'
import './App.css'
import { SiteContextProvider } from './context/SiteContext'
function App(props) {
return (
<HopeProvider>
<NotificationsProvider>
<SiteContextProvider>{props.children}</SiteContextProvider>
</NotificationsProvider>
</HopeProvider>
<SiteContextProvider>
<Toaster
containerStyle={
props.location?.pathname.indexOf('/login') >= 0
? null
: { 'margin-top': '60px' }
}
/>
{props.children}
</SiteContextProvider>
)
}

View File

@ -1,5 +1,5 @@
import { protocol } from './index'
import { POST_LOGIN, POST_LOGOUT } from './url'
import { POST_LOGIN, POST_LOGOUT, POST_REFRESH } from './url'
export const postLogin = (payload) => {
return protocol.post(POST_LOGIN, payload)
@ -8,3 +8,7 @@ export const postLogin = (payload) => {
export const getLogout = () => {
return protocol.get(POST_LOGOUT, {})
}
export const refreshToken = () => {
return protocol.get(POST_REFRESH, {})
}

View File

@ -1,6 +0,0 @@
import { protocol } from './index'
import { GET_DATE } from './url'
export const getWebData = (payload) => {
return protocol.get(`${GET_DATE}?url=${payload}`, {})
}

View File

@ -1,20 +1,37 @@
import { LOGIN_KEY } from '@utils/enum'
import axios from 'axios'
import { Helpers } from '../utils/helper'
import { refreshToken } from './auth'
const protocol = axios.create({
baseURL: '/',
})
const forceLogout = () => {
Helpers.clearCookie()
Helpers.clearStorage()
window.location.href = '/login'
}
protocol.interceptors.request.use(function (config) {
protocol.interceptors.request.use(async (config) => {
config.headers.set(
'Content-Type',
config.headers.get('Content-Type') ?? 'application/json',
)
if (
config.url.indexOf('/login') >= 0 ||
config.url.indexOf('/refresh') >= 0
) {
return config
}
const { accessToken, exp } = await JSON.parse(
Helpers.decrypt(localStorage.getItem(LOGIN_KEY)),
)
if (accessToken && !Helpers.checkTokenExpired(exp)) {
config.headers.set('Authorization', `Bearer ${accessToken}`)
}
return config
})
@ -22,11 +39,36 @@ protocol.interceptors.response.use(
(response) => {
return response.data || {}
},
(error) => {
async (error) => {
const {
response: { status, data },
config,
} = error
if (
config.url.indexOf('/login') >= 0 ||
config.url.indexOf('/refresh') >= 0
) {
return Promise.reject(data)
}
if (status === 401 && !config._retry) {
config._retry = true
try {
// call refresh token
const resp = await refreshToken()
if (resp.status === 200) {
const { data } = resp
localStorage.setItem(LOGIN_KEY, Helpers.encrypt(JSON.stringify(data)))
config.headers['Authorization'] = `Bearer ${data.accessToken}`
return protocol(config)
}
} catch (error) {
forceLogout()
return Promise.reject(error)
}
}
if (status === 403) {
forceLogout()
}

View File

@ -1,3 +1,4 @@
export const POST_LOGIN = '/api/auth/login'
export const POST_LOGOUT = '/api/auth/logout'
export const GET_DATE = '/api/user/get-data/'
export const POST_REFRESH = '/api/auth/refresh'
export const GET_USER_PROFILE = '/api/user/me'

View File

@ -0,0 +1,6 @@
import { protocol } from './index'
import { GET_USER_PROFILE } from './url'
export const getProfile = () => {
return protocol.get(GET_USER_PROFILE, {})
}

View File

@ -0,0 +1,585 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="1835.000000pt" height="2012.000000pt" viewBox="0 0 1835.000000 2012.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,2012.000000) scale(0.100000,-0.100000)"
fill="#ffffff" stroke="none">
<path d="M17135 19631 c-3 -5 -20 -13 -38 -16 -17 -4 -36 -10 -42 -14 -5 -4
-30 -13 -55 -20 -25 -7 -53 -17 -62 -22 -10 -5 -25 -9 -33 -9 -9 0 -26 -6 -38
-14 -12 -8 -44 -18 -72 -21 -27 -4 -55 -11 -60 -16 -11 -8 -67 -27 -145 -49
-25 -6 -56 -18 -70 -24 -14 -7 -45 -18 -70 -25 -25 -7 -53 -17 -62 -22 -10 -5
-25 -9 -33 -9 -8 0 -23 -4 -33 -9 -47 -26 -87 -41 -109 -41 -12 0 -23 -4 -23
-10 0 -5 -16 -10 -35 -10 -19 0 -35 -4 -35 -10 0 -5 -5 -10 -11 -10 -6 0 -27
-7 -47 -16 -72 -31 -141 -54 -164 -54 -9 0 -21 -7 -28 -15 -7 -8 -20 -15 -30
-15 -19 0 -108 -33 -151 -56 -14 -7 -45 -16 -67 -20 -23 -4 -42 -10 -42 -14 0
-5 -15 -12 -32 -15 -18 -4 -37 -10 -43 -14 -5 -4 -28 -13 -50 -20 -22 -7 -49
-16 -60 -21 -11 -5 -38 -16 -60 -25 -22 -9 -48 -21 -57 -26 -10 -5 -25 -9 -33
-9 -8 0 -23 -4 -33 -9 -9 -5 -35 -17 -57 -26 -22 -10 -48 -22 -57 -26 -10 -5
-24 -9 -32 -9 -8 0 -36 -11 -63 -24 -26 -13 -75 -34 -108 -46 -33 -12 -78 -31
-101 -41 -22 -11 -48 -19 -57 -19 -9 0 -19 -4 -22 -10 -3 -5 -17 -10 -30 -10
-13 0 -26 -4 -30 -9 -8 -14 -65 -41 -85 -41 -20 0 -77 -27 -85 -41 -4 -5 -15
-9 -26 -9 -19 0 -28 -4 -76 -28 -13 -7 -29 -12 -37 -12 -7 0 -19 -7 -26 -15
-7 -8 -23 -15 -36 -15 -13 0 -24 -4 -24 -10 0 -5 -9 -10 -19 -10 -11 0 -23 -4
-26 -10 -3 -5 -16 -10 -27 -10 -12 0 -29 -6 -37 -13 -21 -18 -119 -57 -142
-57 -11 0 -19 -4 -19 -8 0 -11 -95 -52 -119 -52 -10 0 -24 -7 -31 -14 -6 -8
-28 -20 -48 -27 -20 -6 -41 -15 -47 -20 -5 -5 -21 -9 -36 -9 -15 0 -29 -7 -33
-15 -3 -8 -12 -15 -21 -15 -8 0 -24 -4 -35 -10 -11 -5 -29 -14 -40 -20 -11 -5
-29 -10 -39 -10 -11 0 -22 -4 -25 -9 -9 -14 -107 -61 -127 -61 -9 0 -22 -7
-29 -15 -7 -8 -18 -15 -25 -15 -6 0 -27 -7 -46 -16 -52 -25 -122 -56 -144 -64
-11 -4 -45 -19 -76 -33 -31 -15 -70 -30 -87 -33 -18 -4 -32 -10 -32 -15 0 -5
-11 -9 -24 -9 -13 0 -26 -6 -29 -13 -3 -7 -24 -19 -48 -27 -24 -7 -48 -17 -54
-22 -5 -4 -19 -8 -32 -8 -13 0 -23 -4 -23 -9 0 -11 -57 -41 -77 -41 -12 0 -29
-7 -73 -31 -8 -5 -31 -16 -50 -25 -19 -8 -43 -20 -52 -25 -10 -5 -27 -9 -37
-9 -11 0 -23 -4 -26 -10 -5 -8 -45 -28 -100 -50 -11 -4 -50 -22 -86 -39 -37
-17 -74 -31 -84 -31 -10 0 -23 -6 -29 -14 -6 -8 -40 -24 -76 -36 -36 -12 -72
-28 -80 -34 -8 -7 -28 -18 -45 -25 -16 -7 -38 -17 -47 -22 -10 -5 -27 -9 -37
-9 -11 0 -23 -4 -26 -10 -5 -8 -43 -27 -100 -50 -22 -9 -88 -39 -207 -94 -43
-20 -83 -36 -90 -36 -7 0 -28 -9 -46 -20 -18 -11 -37 -20 -43 -20 -6 0 -17 -7
-25 -15 -8 -8 -31 -17 -52 -21 -20 -4 -44 -12 -52 -18 -8 -7 -26 -17 -40 -23
-14 -6 -59 -27 -101 -47 -42 -20 -84 -36 -93 -36 -9 0 -16 -4 -16 -10 0 -5
-11 -10 -25 -10 -14 0 -25 -3 -25 -7 0 -12 -59 -43 -80 -43 -10 0 -22 -4 -25
-10 -3 -5 -13 -10 -21 -10 -8 0 -31 -10 -52 -23 -20 -13 -86 -43 -147 -67 -60
-24 -117 -49 -125 -55 -8 -6 -28 -17 -45 -24 -16 -7 -38 -17 -47 -22 -10 -5
-27 -9 -37 -9 -11 0 -22 -4 -26 -9 -7 -13 -64 -41 -82 -41 -7 0 -13 -4 -13
-10 0 -5 -11 -10 -25 -10 -14 0 -25 -4 -25 -10 0 -5 -4 -10 -10 -10 -10 0
-153 -63 -200 -89 -46 -25 -62 -31 -79 -31 -11 0 -23 -4 -26 -10 -3 -5 -15
-10 -25 -10 -10 0 -20 -4 -22 -9 -3 -9 -159 -84 -198 -95 -39 -12 -89 -36 -95
-46 -3 -6 -15 -10 -26 -10 -10 0 -19 -4 -19 -10 0 -5 -11 -10 -25 -10 -14 0
-25 -4 -25 -10 0 -5 -6 -10 -12 -10 -7 0 -38 -12 -68 -26 -30 -15 -66 -31 -80
-37 -14 -6 -32 -16 -40 -23 -8 -7 -46 -22 -85 -35 -38 -13 -74 -29 -78 -36 -4
-7 -13 -13 -20 -13 -7 0 -39 -14 -72 -31 -33 -16 -89 -40 -125 -51 -36 -12
-69 -28 -73 -35 -4 -7 -17 -13 -27 -13 -11 0 -20 -4 -20 -10 0 -5 -7 -10 -15
-10 -14 0 -35 -9 -75 -32 -8 -4 -22 -11 -30 -14 -8 -3 -24 -9 -35 -14 -11 -4
-38 -17 -60 -28 -22 -11 -56 -28 -75 -37 -19 -9 -43 -21 -52 -26 -10 -5 -27
-9 -37 -9 -11 0 -23 -4 -26 -10 -3 -5 -23 -17 -43 -26 -20 -9 -48 -21 -62 -27
-14 -6 -31 -16 -38 -21 -19 -14 -113 -46 -134 -46 -10 0 -18 -4 -18 -10 0 -12
-97 -60 -122 -60 -10 0 -18 -4 -18 -8 0 -9 -70 -42 -88 -42 -13 0 -53 -20 -62
-31 -5 -6 -65 -33 -105 -48 -11 -5 -45 -20 -75 -35 -30 -14 -61 -26 -67 -26
-7 0 -13 -4 -13 -10 0 -5 -9 -10 -19 -10 -11 0 -22 -4 -26 -9 -8 -14 -65 -41
-85 -41 -9 0 -51 -18 -93 -40 -41 -22 -84 -40 -95 -40 -11 0 -22 -7 -26 -15
-3 -8 -12 -15 -21 -15 -8 0 -24 -4 -35 -10 -11 -5 -29 -14 -40 -20 -11 -5 -27
-10 -35 -10 -8 0 -15 -4 -15 -8 0 -5 -19 -16 -42 -26 -24 -9 -51 -21 -60 -27
-10 -5 -24 -9 -32 -9 -7 0 -19 -7 -26 -15 -7 -8 -21 -15 -31 -15 -11 0 -19 -4
-19 -10 0 -5 -11 -10 -25 -10 -14 0 -25 -4 -25 -10 0 -5 -9 -10 -20 -10 -11 0
-20 -4 -20 -8 0 -10 -71 -42 -93 -42 -9 0 -19 -4 -22 -10 -3 -5 -13 -10 -21
-10 -8 0 -32 -11 -53 -25 -22 -13 -52 -27 -68 -31 -15 -4 -35 -12 -43 -19 -8
-7 -33 -19 -55 -26 -22 -7 -44 -17 -49 -21 -6 -4 -18 -8 -27 -8 -10 0 -19 -4
-21 -8 -5 -12 -109 -62 -130 -62 -10 0 -18 -4 -18 -9 0 -5 -13 -12 -30 -16
-16 -4 -30 -11 -30 -16 0 -5 -11 -9 -25 -9 -14 0 -25 -3 -25 -7 0 -7 -94 -54
-145 -74 -11 -4 -54 -23 -96 -43 -42 -20 -82 -36 -88 -36 -6 0 -11 -4 -11 -10
0 -5 -5 -10 -10 -10 -6 0 -30 -9 -52 -20 -23 -11 -47 -20 -54 -20 -12 0 -73
-29 -84 -40 -14 -14 -52 -30 -70 -30 -11 0 -20 -4 -20 -10 0 -5 -11 -12 -25
-16 -14 -3 -25 -10 -25 -15 0 -5 -7 -9 -15 -9 -8 0 -23 -4 -33 -9 -9 -5 -44
-21 -77 -36 -33 -15 -77 -36 -98 -46 -22 -10 -45 -19 -52 -19 -7 0 -15 -7 -19
-15 -3 -8 -12 -15 -19 -15 -8 0 -27 -6 -43 -14 -16 -8 -51 -24 -79 -36 -27
-12 -77 -35 -110 -51 -33 -16 -66 -29 -73 -29 -6 0 -12 -4 -12 -10 0 -5 -6
-10 -13 -10 -18 0 -75 -28 -82 -41 -4 -5 -15 -9 -26 -9 -10 0 -19 -4 -19 -10
0 -5 -6 -10 -14 -10 -8 0 -38 -12 -68 -26 -29 -15 -64 -31 -78 -36 -34 -14
-47 -21 -103 -51 -26 -15 -54 -27 -62 -27 -7 0 -15 -3 -17 -7 -3 -8 -129 -73
-141 -73 -3 0 -23 -11 -43 -25 -20 -14 -47 -25 -60 -25 -13 0 -24 -4 -24 -9 0
-5 -8 -11 -17 -15 -10 -3 -25 -9 -33 -14 -37 -22 -61 -32 -74 -32 -8 0 -16 -3
-18 -7 -3 -8 -32 -22 -193 -98 -44 -20 -96 -45 -115 -55 -19 -11 -51 -26 -70
-35 -97 -46 -105 -52 -108 -73 -2 -12 -8 -22 -13 -22 -5 0 -9 -10 -9 -23 0
-13 -6 -32 -14 -42 -12 -17 -12 -23 0 -47 8 -15 14 -40 14 -57 0 -16 5 -33 10
-36 6 -3 10 -15 10 -26 0 -18 18 -58 31 -69 6 -5 22 -35 51 -90 7 -14 17 -28
23 -32 5 -4 19 -31 30 -61 21 -57 85 -137 109 -137 8 0 36 -21 62 -47 42 -41
53 -46 91 -45 42 0 103 20 103 34 0 9 59 38 77 38 7 0 13 5 13 10 0 6 11 10
25 10 14 0 25 4 25 10 0 5 26 21 58 35 31 14 64 30 72 35 8 6 38 22 65 36 28
14 73 38 100 54 28 16 56 29 63 29 7 1 28 12 46 26 18 14 39 25 47 26 8 0 28
9 44 19 52 32 88 50 102 50 7 0 13 5 13 10 0 6 9 10 19 10 11 0 22 4 26 9 7
13 64 41 82 41 7 0 13 5 13 10 0 6 9 10 19 10 11 0 22 4 25 9 3 5 59 34 123
66 65 31 127 61 138 67 62 34 115 58 129 58 9 0 16 4 16 9 0 5 24 19 53 31 56
24 213 97 237 111 8 4 40 20 70 34 30 15 66 33 80 41 52 31 114 55 127 50 11
-5 13 -34 9 -153 -3 -82 -11 -337 -18 -568 -7 -240 -17 -426 -23 -435 -5 -8
-13 -109 -17 -225 -4 -115 -12 -313 -18 -440 -6 -126 -14 -327 -18 -445 -4
-141 -11 -223 -19 -237 -9 -15 -13 -82 -13 -230 0 -121 -4 -213 -10 -219 -5
-5 -12 -108 -14 -229 -11 -449 -21 -680 -31 -695 -10 -15 -20 -254 -31 -690
-2 -124 -9 -229 -14 -234 -6 -6 -10 -87 -10 -187 0 -148 -3 -179 -16 -190 -28
-23 -196 -109 -214 -109 -6 0 -10 -4 -10 -8 0 -5 -28 -21 -62 -37 -35 -16 -79
-39 -98 -51 -19 -11 -52 -26 -72 -33 -21 -7 -38 -16 -38 -19 0 -6 -52 -34 -70
-38 -11 -2 -57 -26 -85 -43 -16 -11 -38 -20 -47 -20 -10 -1 -18 -5 -18 -11 0
-5 -9 -10 -19 -10 -11 0 -22 -4 -26 -9 -7 -13 -64 -41 -82 -41 -7 0 -13 -4
-13 -10 0 -5 -9 -10 -20 -10 -11 0 -23 -7 -26 -15 -4 -8 -15 -15 -25 -15 -10
0 -19 -4 -19 -10 0 -5 -7 -10 -15 -10 -8 0 -36 -12 -62 -27 -53 -29 -64 -34
-108 -54 -16 -7 -37 -19 -45 -25 -8 -7 -18 -13 -22 -14 -14 -2 -83 -30 -98
-40 -14 -9 -50 -26 -110 -53 -14 -7 -39 -22 -56 -34 -17 -13 -36 -23 -42 -23
-6 0 -33 -12 -59 -27 -26 -15 -66 -36 -88 -47 -22 -12 -42 -23 -45 -26 -3 -3
-41 -24 -85 -46 -44 -22 -89 -46 -100 -52 -45 -25 -191 -92 -202 -92 -6 0 -13
-4 -15 -8 -4 -11 -108 -62 -125 -62 -7 0 -13 -4 -13 -10 0 -5 -11 -12 -25 -16
-14 -3 -25 -10 -25 -15 0 -5 -9 -9 -19 -9 -11 0 -23 -4 -26 -10 -3 -5 -14 -10
-25 -10 -10 0 -20 -7 -24 -15 -3 -8 -11 -15 -18 -15 -7 0 -24 -9 -38 -20 -14
-11 -31 -20 -39 -20 -8 0 -28 -10 -45 -23 -31 -22 -53 -34 -113 -59 -18 -7
-33 -16 -33 -20 0 -3 -17 -12 -37 -18 -21 -7 -55 -23 -75 -36 -21 -13 -42 -24
-47 -24 -10 0 -62 -28 -153 -81 -27 -16 -55 -29 -63 -29 -8 0 -15 -4 -15 -9 0
-11 -56 -41 -77 -41 -7 0 -13 -4 -13 -10 0 -5 -9 -10 -20 -10 -11 0 -23 -7
-26 -15 -4 -8 -12 -15 -20 -15 -7 0 -29 -9 -49 -20 -20 -11 -42 -20 -50 -20
-8 0 -15 -4 -15 -9 0 -6 -21 -21 -47 -34 -100 -51 -129 -66 -163 -82 -64 -30
-140 -74 -156 -90 -8 -8 -22 -15 -30 -15 -8 0 -14 -4 -14 -10 0 -5 -6 -10 -13
-10 -18 0 -75 -28 -82 -41 -4 -5 -15 -9 -25 -9 -10 0 -20 -4 -22 -9 -6 -16
-165 -101 -188 -101 -6 0 -10 -4 -10 -9 0 -5 -24 -21 -52 -35 -29 -15 -71 -38
-93 -52 -22 -13 -50 -29 -62 -34 -13 -5 -23 -14 -23 -20 0 -5 -7 -10 -15 -10
-17 0 -76 -32 -120 -66 -18 -13 -39 -24 -47 -24 -8 0 -23 -9 -33 -20 -9 -10
-40 -31 -69 -46 -28 -14 -55 -33 -59 -40 -4 -8 -14 -14 -22 -14 -8 0 -30 -13
-48 -30 -19 -16 -39 -30 -43 -30 -21 -1 -64 -51 -64 -74 0 -14 -5 -28 -10 -31
-13 -8 -13 -132 0 -140 6 -3 10 -22 10 -41 0 -19 4 -34 9 -34 11 0 41 -56 41
-76 0 -7 11 -21 25 -32 14 -11 25 -24 25 -29 0 -11 42 -97 57 -115 6 -7 16
-29 22 -49 13 -40 81 -118 121 -139 27 -14 59 -41 93 -77 39 -43 129 -21 194
45 10 10 38 30 63 43 25 13 54 32 65 42 11 10 38 27 60 37 22 10 49 28 59 39
11 12 25 21 33 21 16 0 50 18 78 42 11 9 52 33 90 53 39 20 74 40 80 46 5 5
17 9 27 9 10 0 18 4 18 9 0 11 56 41 77 41 7 0 13 5 13 10 0 6 5 10 11 10 6 0
25 11 43 25 18 14 40 25 49 25 10 0 17 5 17 10 0 6 9 10 20 10 11 0 20 4 20
10 0 5 27 22 60 37 33 14 60 30 60 35 0 4 5 8 12 8 6 0 19 6 27 13 9 8 32 20
51 27 19 8 37 17 40 21 3 3 30 19 60 33 30 15 78 40 105 56 28 16 58 29 68 29
9 1 17 5 17 10 0 11 56 41 77 41 7 0 13 5 13 10 0 6 11 10 24 10 13 0 26 7 30
15 3 8 31 27 62 42 86 42 94 47 94 55 0 5 7 8 15 8 8 0 36 12 62 27 54 30 64
35 113 58 35 17 114 59 203 108 26 15 54 27 62 27 8 0 15 3 15 8 0 10 58 42
76 42 8 0 14 5 14 10 0 6 11 10 25 10 14 0 25 4 25 9 0 4 39 29 88 53 154 80
202 106 215 116 6 5 23 13 37 17 14 4 43 19 64 33 22 13 44 25 50 27 17 3 58
23 91 44 17 11 36 20 43 20 7 1 29 12 50 26 39 26 145 83 252 136 36 18 67 36
68 41 2 4 10 8 18 8 7 0 29 9 49 20 20 11 42 20 49 20 8 0 16 6 19 14 3 7 18
17 34 21 15 3 53 22 84 41 31 19 64 34 73 34 9 0 16 4 16 9 0 5 8 11 18 15 9
3 31 14 47 25 17 11 38 20 48 20 9 1 17 5 17 10 0 5 8 11 18 15 9 3 24 9 32
14 38 22 61 32 75 32 8 0 15 4 15 9 0 5 8 11 18 15 9 3 24 10 32 15 8 5 40 21
70 36 30 15 82 42 115 60 106 59 124 67 134 60 18 -11 14 -450 -4 -503 -11
-32 -15 -92 -14 -257 0 -118 -3 -221 -8 -227 -8 -12 -16 -244 -28 -733 -3
-115 -10 -240 -15 -277 -6 -37 -10 -148 -10 -247 0 -99 -4 -224 -10 -278 -5
-54 -12 -217 -15 -363 -3 -146 -9 -429 -13 -630 -4 -214 -11 -371 -17 -380 -6
-9 -13 -190 -18 -450 -38 -2158 -40 -2240 -54 -2273 -9 -19 -13 -86 -13 -209
0 -161 2 -182 19 -204 18 -22 19 -23 35 -5 12 13 16 37 16 94 0 42 5 79 10 82
6 4 10 54 10 119 0 61 4 116 9 121 5 6 11 61 13 123 2 73 7 115 15 120 7 5 14
48 17 112 14 259 18 306 27 315 5 5 9 48 9 95 0 56 5 92 14 105 9 14 16 72 21
190 5 112 12 179 21 197 8 16 14 58 14 106 0 43 4 82 9 87 5 6 12 53 15 105 4
52 9 137 12 189 3 57 11 103 20 115 9 14 14 48 14 108 0 48 5 90 10 93 6 3 10
48 10 100 0 52 4 97 10 100 6 3 10 50 10 105 0 55 4 102 10 105 6 3 10 42 10
87 0 49 6 92 15 111 8 18 17 77 20 132 3 55 8 145 11 200 3 55 10 104 15 110
5 5 9 50 9 100 0 65 4 97 15 111 10 14 14 47 15 121 0 57 4 105 10 108 6 3 10
52 10 110 0 58 4 107 10 110 6 3 10 52 10 110 0 76 4 107 14 118 14 14 15 30
32 357 3 58 9 109 15 115 5 5 9 53 9 106 0 60 5 109 14 130 10 23 16 101 21
244 4 116 11 215 15 220 4 6 10 60 12 121 2 65 8 117 15 125 6 8 14 63 17 124
3 61 10 166 16 235 5 69 13 180 17 247 5 75 13 127 21 135 8 8 12 49 12 128 0
64 4 120 9 125 6 6 12 62 15 125 14 307 20 353 46 391 14 22 39 42 60 49 19 7
46 21 59 32 14 10 43 28 65 38 23 11 64 33 91 49 28 16 57 30 66 30 9 1 19 8
23 16 3 8 12 15 20 15 9 0 31 9 51 20 20 11 42 20 50 20 8 0 15 4 15 10 0 5
26 21 58 36 31 14 59 29 62 32 11 15 89 52 109 52 11 0 21 4 21 10 0 10 95 60
114 60 6 0 22 12 35 25 13 14 32 25 42 25 10 0 19 3 19 8 0 8 18 18 145 79 17
7 44 22 60 33 17 10 38 19 48 19 9 1 17 4 17 9 0 8 7 12 90 55 30 16 78 41
105 57 28 15 60 29 73 29 12 1 22 5 22 10 0 11 87 61 106 61 8 0 14 4 14 9 0
10 97 61 117 61 7 0 13 3 13 8 0 8 57 42 71 42 5 0 32 15 61 33 29 18 79 46
110 61 32 15 60 31 63 36 3 5 20 12 38 15 17 4 34 11 37 15 10 14 90 60 104
60 8 0 16 4 18 8 5 14 97 62 118 62 11 0 20 4 20 10 0 5 19 19 43 30 23 11 60
31 82 44 22 14 78 44 125 68 47 23 103 54 125 67 60 38 86 51 100 51 7 0 15 4
17 8 3 9 107 62 120 62 5 0 19 9 31 20 25 24 74 50 94 50 7 0 13 3 13 8 0 8
11 14 77 45 21 10 45 23 53 28 140 85 152 89 180 64 11 -10 20 -24 20 -32 0
-8 11 -26 25 -41 14 -15 25 -32 25 -39 0 -7 5 -13 10 -13 6 0 10 -9 10 -19 0
-11 3 -21 8 -23 12 -5 62 -87 62 -102 0 -8 3 -16 8 -18 8 -3 62 -84 62 -94 0
-3 15 -29 34 -57 18 -29 44 -71 56 -94 13 -24 27 -43 32 -43 4 0 8 -11 8 -25
0 -14 5 -25 10 -25 6 0 18 -16 27 -35 9 -19 20 -35 25 -35 4 0 8 -7 8 -15 0
-8 16 -37 35 -64 19 -26 35 -52 35 -55 0 -4 15 -31 33 -59 18 -29 41 -68 51
-87 10 -19 26 -44 36 -55 9 -11 24 -36 33 -56 9 -20 23 -42 32 -49 8 -7 15
-21 15 -31 0 -11 5 -19 10 -19 6 0 10 -6 10 -14 0 -8 11 -28 25 -44 14 -17 25
-37 25 -46 0 -9 5 -16 10 -16 6 0 10 -6 10 -13 0 -7 11 -24 25 -39 14 -15 25
-31 25 -36 0 -15 30 -69 45 -82 18 -15 45 -68 45 -87 0 -7 7 -16 16 -20 8 -3
26 -30 40 -59 13 -29 28 -55 33 -59 12 -7 41 -64 41 -80 0 -7 7 -15 15 -19 8
-3 26 -29 39 -58 14 -30 34 -62 45 -72 12 -11 21 -27 21 -38 0 -10 5 -18 10
-18 6 0 10 -9 10 -19 0 -10 6 -21 13 -24 13 -5 57 -81 57 -99 0 -6 11 -19 25
-30 14 -11 25 -27 26 -36 0 -9 8 -29 17 -43 29 -44 56 -87 77 -121 11 -18 28
-44 37 -58 9 -14 17 -35 17 -47 1 -13 6 -23 12 -23 16 0 38 -31 39 -52 0 -10
5 -18 10 -18 6 0 10 -7 10 -16 0 -9 11 -25 25 -36 14 -11 25 -26 25 -34 0 -17
18 -50 43 -78 21 -25 47 -74 47 -91 0 -7 7 -15 15 -19 8 -3 26 -30 40 -60 14
-30 30 -58 36 -62 6 -3 20 -25 30 -48 10 -23 27 -51 39 -61 11 -10 20 -26 20
-37 0 -10 5 -18 10 -18 6 0 10 -8 10 -18 0 -10 11 -29 25 -42 14 -13 25 -32
25 -42 0 -10 5 -18 10 -18 6 0 10 -6 10 -13 0 -7 11 -24 25 -39 14 -15 25 -32
25 -38 0 -6 15 -32 32 -58 18 -26 44 -67 57 -92 13 -25 27 -47 31 -50 6 -5 21
-31 52 -90 7 -14 15 -27 18 -30 4 -3 12 -20 19 -37 8 -18 18 -33 23 -33 5 0
18 -20 29 -45 11 -24 25 -50 32 -57 19 -20 47 -66 47 -78 0 -6 8 -20 18 -30
10 -11 29 -40 41 -65 12 -25 28 -51 34 -58 19 -20 36 -49 48 -80 6 -15 15 -27
19 -27 4 0 13 -12 19 -28 17 -41 45 -86 59 -95 6 -4 12 -15 12 -23 0 -8 9 -24
20 -36 11 -12 20 -30 20 -40 0 -10 4 -18 9 -18 9 0 35 -39 74 -110 10 -19 28
-44 38 -56 10 -11 19 -26 19 -32 0 -7 16 -35 35 -62 19 -27 35 -55 35 -60 0
-6 8 -20 18 -30 10 -11 28 -40 41 -65 12 -24 26 -47 31 -50 11 -7 40 -64 40
-79 0 -6 11 -20 25 -30 14 -10 25 -27 25 -37 0 -11 5 -19 10 -19 6 0 10 -6 10
-14 0 -7 11 -25 25 -40 14 -15 25 -36 25 -47 0 -10 4 -19 8 -19 4 0 16 -15 27
-32 10 -18 21 -35 24 -38 4 -3 12 -16 19 -30 7 -14 21 -38 32 -55 35 -54 49
-80 62 -108 7 -15 16 -27 20 -27 5 0 19 -24 33 -53 13 -30 31 -60 40 -67 9 -7
24 -32 35 -54 10 -23 28 -50 39 -60 12 -11 21 -27 21 -37 0 -10 5 -21 10 -24
15 -10 60 -82 60 -97 0 -7 11 -22 25 -32 14 -10 25 -25 25 -33 0 -13 65 -121
90 -150 5 -7 10 -19 10 -28 0 -8 4 -15 9 -15 10 0 61 -86 61 -102 0 -6 11 -19
25 -30 14 -11 25 -28 25 -38 0 -10 3 -20 8 -22 13 -6 62 -76 62 -89 0 -7 10
-23 21 -35 24 -26 42 -55 61 -96 7 -16 16 -28 20 -28 4 0 21 -26 37 -58 16
-32 36 -64 45 -71 9 -8 16 -19 16 -26 0 -7 11 -23 24 -37 12 -14 26 -32 29
-39 4 -8 18 -32 32 -54 14 -22 28 -47 32 -55 4 -8 15 -24 25 -34 10 -11 18
-26 18 -34 0 -8 11 -23 25 -34 14 -11 25 -27 25 -37 0 -10 11 -27 25 -39 14
-12 25 -28 25 -35 0 -8 9 -22 20 -32 11 -10 20 -23 20 -30 0 -6 11 -22 25 -35
14 -13 25 -29 25 -35 0 -7 11 -24 24 -38 14 -15 27 -36 31 -47 3 -11 11 -20
16 -20 5 0 9 -7 9 -15 0 -8 5 -15 11 -15 14 0 4 77 -13 97 -17 20 -58 105 -58
118 0 7 -7 18 -15 25 -8 7 -15 23 -15 36 0 12 -4 26 -10 29 -5 3 -10 15 -10
26 0 10 -4 19 -10 19 -5 0 -10 9 -10 20 0 11 -7 23 -15 26 -8 4 -15 15 -15 25
0 10 -4 19 -10 19 -5 0 -10 9 -10 19 0 11 -4 23 -10 26 -5 3 -10 14 -10 25 0
10 -7 20 -15 24 -8 3 -15 12 -15 21 0 8 -4 23 -10 33 -33 61 -81 170 -86 199
-3 18 -11 37 -18 41 -6 4 -17 21 -25 37 -7 17 -17 38 -22 47 -5 10 -9 25 -9
33 0 8 -4 15 -9 15 -11 0 -41 56 -41 77 0 7 -4 13 -10 13 -5 0 -10 11 -10 25
0 14 -4 25 -9 25 -11 0 -41 56 -41 77 0 7 -4 13 -10 13 -5 0 -10 9 -10 19 0
11 -4 22 -9 26 -6 3 -22 31 -36 63 -15 31 -31 64 -36 72 -18 30 -59 121 -59
130 0 6 -3 10 -8 10 -9 0 -52 93 -52 114 0 9 -4 16 -9 16 -11 0 -41 56 -41 77
0 7 -4 13 -10 13 -5 0 -10 11 -10 25 0 14 -4 25 -9 25 -11 0 -41 56 -41 77 0
7 -4 13 -10 13 -5 0 -10 9 -10 19 0 11 -4 23 -10 26 -5 3 -23 34 -40 68 -16
34 -51 98 -76 142 -25 44 -52 96 -60 115 -8 19 -19 42 -24 50 -23 37 -60 115
-60 126 0 7 -4 14 -8 16 -11 4 -62 108 -62 125 0 7 -4 13 -10 13 -5 0 -12 11
-16 25 -3 14 -10 25 -15 25 -5 0 -9 7 -9 15 0 14 -38 87 -70 135 -9 14 -24 41
-34 60 -9 19 -21 42 -26 50 -5 8 -21 41 -35 72 -14 31 -29 59 -34 63 -5 3 -13
20 -17 38 -3 17 -17 48 -30 67 -13 19 -24 40 -24 47 0 7 -4 13 -10 13 -5 0
-10 7 -10 17 0 9 -10 30 -23 47 -13 17 -36 57 -51 88 -15 32 -31 60 -37 63 -5
4 -9 15 -9 26 0 10 -4 19 -10 19 -5 0 -10 6 -10 13 0 14 -6 26 -70 142 -22 39
-51 95 -66 125 -15 30 -29 57 -33 60 -3 3 -12 19 -20 35 -7 17 -17 38 -22 47
-5 10 -9 25 -9 33 0 8 -4 15 -9 15 -11 0 -41 56 -41 76 0 7 -4 14 -9 16 -13 5
-61 86 -61 103 0 8 -4 15 -10 15 -5 0 -10 6 -10 14 0 7 -7 19 -15 26 -8 7 -15
21 -15 31 0 11 -4 19 -10 19 -5 0 -10 8 -11 18 0 9 -9 31 -19 47 -11 17 -31
53 -45 80 -15 28 -39 73 -55 100 -16 28 -29 58 -29 68 -1 10 -8 20 -16 23 -8
4 -15 10 -15 16 0 5 -9 28 -20 50 -11 23 -20 47 -20 54 0 6 -6 14 -12 17 -7 2
-26 29 -41 58 -16 30 -37 68 -47 84 -10 17 -19 38 -19 48 -1 9 -5 17 -11 17
-5 0 -10 8 -10 18 0 10 -5 23 -11 29 -6 6 -23 35 -38 64 -51 100 -92 174 -102
183 -5 6 -9 18 -9 28 0 10 -4 18 -8 18 -4 0 -14 16 -21 35 -7 19 -28 58 -47
86 -19 28 -34 57 -34 65 0 8 -4 14 -10 14 -5 0 -12 11 -16 25 -3 14 -10 25
-15 25 -5 0 -9 9 -9 19 0 11 -4 23 -10 26 -5 3 -10 14 -10 25 0 10 -7 20 -15
24 -8 3 -15 14 -15 25 0 11 -3 21 -7 23 -10 4 -33 45 -85 148 -23 47 -45 87
-50 88 -4 2 -8 15 -8 28 0 13 -4 24 -10 24 -5 0 -10 7 -10 15 0 8 -4 15 -8 15
-5 0 -23 28 -41 63 -18 34 -45 85 -61 112 -15 28 -29 58 -29 68 -1 9 -5 17
-10 17 -5 0 -14 12 -20 28 -16 38 -60 114 -77 133 -8 8 -14 20 -14 26 0 11
-74 156 -90 178 -20 27 -60 107 -60 120 0 8 -4 15 -10 15 -5 0 -12 11 -16 25
-3 14 -10 25 -15 25 -5 0 -9 6 -9 13 0 20 -28 73 -45 87 -9 7 -22 29 -31 49
-19 45 -24 54 -57 114 -15 26 -27 54 -27 62 0 8 -4 15 -9 15 -5 0 -21 24 -36
53 -15 28 -35 66 -45 82 -10 17 -19 38 -19 48 -1 9 -5 17 -11 17 -5 0 -10 7
-10 15 0 8 -16 39 -35 69 -19 30 -35 58 -35 61 0 4 -7 13 -15 22 -8 8 -13 19
-9 24 3 5 -2 12 -10 15 -9 3 -16 12 -16 20 0 13 -43 97 -63 122 -11 14 14 48
48 64 33 15 66 35 78 47 6 6 19 11 29 11 10 0 21 7 24 15 4 8 10 15 16 15 5 0
28 9 50 20 23 11 47 20 54 20 6 0 14 6 17 13 2 6 29 25 58 40 30 16 68 37 84
47 17 10 38 19 48 19 9 1 17 6 17 11 0 6 8 10 19 10 10 0 24 7 31 15 7 8 17
15 22 15 6 0 29 13 52 28 23 16 69 41 101 57 33 16 82 42 108 57 26 15 54 28
62 28 8 0 15 4 15 9 0 10 97 61 116 61 7 0 17 6 21 13 10 16 49 37 68 37 8 0
15 5 15 10 0 6 5 10 11 10 6 0 25 11 43 25 18 14 39 25 47 26 8 0 28 9 44 19
47 29 87 50 97 50 6 0 22 8 36 19 43 30 102 61 116 61 8 0 16 7 20 15 3 8 15
15 26 15 11 0 20 3 20 8 0 7 48 32 62 32 5 0 19 9 31 20 12 12 32 23 44 26 13
4 23 10 23 15 0 5 9 9 19 9 11 0 23 5 26 10 8 13 104 60 122 60 7 0 13 4 13 8
0 5 10 14 23 20 12 7 49 28 82 47 33 20 67 38 75 41 46 18 165 82 207 112 17
12 38 22 47 22 9 0 16 5 16 10 0 6 11 10 25 10 14 0 25 4 25 9 0 5 26 22 58
37 31 16 59 31 62 34 3 4 12 10 20 13 8 4 29 16 45 26 17 11 38 20 48 20 9 1
17 5 17 10 0 5 8 11 18 15 9 3 24 9 32 14 8 5 35 20 60 32 57 29 137 72 196
105 24 14 51 25 59 25 8 0 15 4 15 10 0 5 11 12 25 16 14 3 25 9 25 13 0 3 15
12 33 20 17 8 34 17 37 20 7 9 41 28 75 45 94 44 92 42 266 138 75 42 109 60
164 86 22 11 58 30 80 42 22 13 51 30 65 37 14 8 39 23 55 33 17 10 38 19 48
19 9 1 17 6 17 11 0 6 9 10 20 10 11 0 23 7 26 15 4 8 12 15 20 15 7 0 30 10
51 21 21 12 67 38 103 57 36 19 72 41 80 47 8 6 38 20 65 30 28 10 52 21 55
25 3 4 23 15 45 25 22 10 51 26 65 35 46 31 121 70 134 70 8 0 16 7 20 15 3 8
15 15 26 15 11 0 20 5 20 10 0 6 8 10 18 11 9 0 31 9 47 20 17 10 37 22 45 26
8 3 47 25 85 48 39 23 87 48 108 54 20 7 37 16 37 19 0 4 15 13 33 20 58 24
82 36 112 58 17 11 46 29 65 38 19 10 58 30 85 46 28 15 58 29 68 29 9 1 17 5
17 11 0 5 11 12 25 16 14 3 25 10 25 14 0 4 11 11 24 14 14 3 31 12 39 20 16
16 87 56 100 56 5 0 29 12 55 27 26 16 50 28 54 28 3 0 10 3 14 8 4 4 15 7 25
7 10 0 22 6 26 13 11 19 104 71 213 120 14 7 39 21 55 32 17 12 44 28 60 36
17 7 36 20 43 27 7 6 20 12 28 12 8 0 14 5 14 10 0 6 6 10 13 10 17 0 75 28
82 40 5 8 34 23 85 44 8 3 33 18 55 31 22 14 48 28 58 32 9 3 17 9 17 13 0 10
57 40 75 40 7 0 20 9 31 21 10 11 37 29 60 40 23 10 48 25 56 32 7 7 34 23 60
36 25 12 52 29 58 37 7 7 17 14 23 14 6 0 19 8 29 17 11 9 42 29 71 44 40 20
53 32 55 53 3 21 -1 26 -17 26 -12 0 -21 -4 -21 -10 0 -5 -17 -10 -38 -10 -21
0 -46 -6 -57 -14 -11 -7 -40 -16 -65 -19 -102 -14 -130 -20 -136 -28 -3 -5
-18 -9 -33 -9 -16 0 -34 -7 -41 -15 -7 -8 -27 -15 -46 -15 -18 0 -36 -4 -39
-10 -3 -5 -22 -10 -41 -10 -19 0 -34 -4 -34 -10 0 -5 -14 -10 -30 -10 -18 0
-33 -6 -36 -15 -4 -8 -19 -15 -34 -15 -16 0 -32 -4 -35 -10 -3 -5 -15 -10 -26
-10 -19 0 -27 -3 -86 -34 -17 -9 -40 -16 -51 -16 -12 0 -24 -4 -27 -10 -3 -5
-14 -10 -24 -10 -9 0 -55 -16 -101 -35 -47 -19 -102 -38 -122 -41 -21 -4 -43
-13 -49 -20 -6 -8 -22 -14 -35 -14 -13 0 -24 -4 -24 -10 0 -5 -11 -10 -25 -10
-23 0 -41 -7 -85 -32 -8 -4 -22 -11 -30 -14 -8 -3 -23 -10 -32 -15 -10 -5 -29
-9 -43 -9 -14 0 -25 -4 -25 -10 0 -5 -11 -10 -24 -10 -13 0 -26 -7 -30 -15 -3
-9 -18 -15 -36 -15 -16 0 -30 -4 -30 -10 0 -5 -11 -10 -25 -10 -14 0 -25 -4
-25 -10 0 -5 -11 -10 -24 -10 -13 0 -29 -7 -36 -15 -7 -8 -19 -15 -26 -15 -8
0 -22 -4 -32 -9 -9 -5 -35 -14 -57 -21 -22 -7 -47 -18 -55 -24 -8 -7 -42 -20
-75 -30 -33 -10 -67 -23 -75 -30 -8 -7 -33 -18 -55 -25 -46 -14 -83 -29 -105
-42 -8 -5 -22 -12 -30 -15 -8 -3 -26 -11 -40 -16 -14 -6 -36 -15 -50 -21 -14
-5 -37 -16 -52 -23 -14 -8 -33 -14 -42 -14 -9 0 -16 -4 -16 -10 0 -5 -7 -10
-15 -10 -8 0 -23 -4 -33 -9 -25 -13 -134 -62 -157 -71 -11 -4 -31 -12 -45 -18
-90 -39 -132 -58 -188 -83 -34 -16 -76 -32 -92 -36 -17 -3 -30 -9 -30 -12 0
-8 -52 -31 -115 -52 -22 -8 -44 -20 -48 -26 -4 -7 -17 -13 -27 -13 -11 0 -20
-4 -20 -10 0 -5 -11 -10 -25 -10 -14 0 -25 -4 -25 -10 0 -5 -13 -10 -29 -10
-16 0 -31 -6 -35 -15 -3 -8 -12 -15 -20 -15 -9 0 -31 -9 -51 -20 -20 -11 -42
-20 -50 -20 -8 0 -15 -3 -15 -7 0 -5 -21 -16 -48 -26 -26 -10 -84 -36 -128
-57 -45 -22 -88 -40 -95 -40 -8 0 -23 -7 -33 -15 -11 -8 -28 -15 -38 -15 -10
0 -18 -4 -18 -10 0 -5 -9 -10 -19 -10 -11 0 -23 -4 -26 -10 -3 -5 -15 -10 -26
-10 -10 0 -19 -4 -19 -9 0 -12 -58 -41 -82 -41 -10 0 -18 -4 -18 -10 0 -5 -13
-10 -30 -10 -16 0 -30 -3 -30 -8 0 -4 -17 -16 -37 -26 -21 -10 -46 -22 -55
-27 -10 -5 -25 -9 -33 -9 -8 0 -15 -4 -15 -9 0 -5 -15 -15 -32 -22 -18 -6 -46
-17 -63 -24 -67 -25 -115 -49 -115 -57 0 -4 -6 -8 -14 -8 -8 0 -49 -18 -92
-40 -43 -22 -84 -40 -91 -40 -7 0 -44 -16 -82 -35 -37 -19 -71 -35 -75 -35 -3
0 -24 -11 -46 -25 -22 -14 -46 -25 -55 -25 -8 0 -15 -4 -15 -10 0 -5 -11 -10
-24 -10 -14 0 -28 -4 -31 -10 -3 -5 -14 -10 -24 -10 -10 0 -24 -7 -31 -15 -7
-8 -21 -15 -31 -15 -11 0 -19 -4 -19 -10 0 -5 -8 -10 -17 -11 -10 0 -31 -9
-48 -19 -45 -28 -161 -82 -227 -106 -20 -7 -63 -26 -95 -42 -32 -16 -71 -36
-88 -43 -16 -8 -32 -17 -35 -20 -3 -3 -23 -14 -45 -24 -45 -19 -141 -63 -167
-76 -10 -5 -25 -9 -33 -9 -8 0 -15 -4 -15 -10 0 -5 -9 -10 -19 -10 -11 0 -22
-4 -25 -9 -8 -12 -106 -61 -122 -61 -7 0 -17 -6 -21 -13 -4 -8 -30 -22 -58
-32 -27 -10 -68 -28 -90 -40 -22 -12 -60 -28 -85 -36 -25 -7 -49 -19 -53 -26
-4 -7 -17 -13 -27 -13 -11 0 -20 -4 -20 -10 0 -5 -9 -10 -19 -10 -11 0 -23 -4
-26 -10 -3 -5 -14 -10 -25 -10 -10 0 -20 -7 -24 -15 -3 -8 -15 -15 -26 -15
-11 0 -20 -4 -20 -10 0 -5 -6 -10 -13 -10 -18 0 -75 -28 -82 -41 -4 -5 -15 -9
-26 -9 -10 0 -19 -4 -19 -10 0 -5 -7 -10 -15 -10 -8 0 -23 -4 -33 -9 -9 -5
-42 -20 -72 -34 -78 -35 -121 -56 -150 -73 -41 -23 -60 -18 -60 15 0 17 5 33
10 36 6 4 28 34 50 68 22 34 43 67 48 72 4 6 26 39 47 75 22 36 45 72 50 81 6
9 27 42 48 73 20 31 37 61 37 67 0 5 7 12 15 15 8 4 15 11 15 18 0 6 9 22 20
36 11 14 20 32 20 41 0 9 11 22 25 29 14 7 25 22 25 32 0 18 46 89 63 96 4 2
7 11 7 20 0 8 7 24 17 34 17 19 33 44 55 88 7 14 15 27 19 30 3 3 14 20 24 38
11 17 23 32 27 32 4 0 8 9 8 19 0 11 11 28 25 39 14 11 25 29 25 41 0 12 5 21
10 21 6 0 10 6 10 14 0 7 11 25 25 40 14 15 25 33 25 40 0 8 7 20 16 27 9 7
20 22 25 34 5 11 21 38 35 60 13 22 27 48 31 58 3 9 9 17 13 17 5 0 20 24 34
53 13 29 34 61 45 71 12 11 21 26 21 34 0 8 16 36 35 62 19 26 35 51 35 55 0
4 16 29 35 55 19 26 35 53 35 59 0 7 11 24 25 39 14 15 25 32 25 39 0 7 5 13
10 13 6 0 10 9 10 19 0 11 11 28 25 39 14 11 25 28 26 38 0 11 8 30 17 44 9
14 26 41 37 59 11 18 30 47 42 65 12 17 34 55 49 84 15 30 33 56 41 59 7 3 13
12 13 19 0 12 44 88 60 104 3 3 16 25 29 50 13 25 30 52 37 61 8 8 14 21 14
27 0 7 4 12 8 12 4 0 13 12 20 28 7 15 23 45 37 67 13 22 29 49 35 60 6 11 19
34 30 50 11 17 25 41 32 55 7 14 18 31 25 38 7 7 13 20 13 28 0 8 4 14 8 14 5
0 17 15 27 34 14 26 38 44 94 72 42 21 78 41 81 44 9 11 72 40 87 40 7 0 13 4
13 9 0 5 8 11 18 15 9 3 31 14 47 25 17 11 40 20 51 20 12 1 24 7 27 14 3 8
30 26 61 41 31 15 58 31 61 37 4 5 13 9 21 9 8 0 38 15 67 33 29 18 66 38 82
46 17 7 37 17 45 22 8 5 22 12 30 16 8 4 17 9 20 13 3 3 21 14 40 23 19 10 42
21 50 26 8 5 29 15 45 22 17 8 44 24 61 36 17 13 46 28 64 35 19 6 49 21 67
32 96 62 123 77 152 82 17 4 31 10 31 14 0 5 26 22 58 37 31 16 73 39 92 51
19 12 40 22 47 22 7 0 23 10 37 23 14 13 44 30 68 37 24 7 48 19 53 25 6 6 25
18 43 26 17 7 32 17 32 20 0 4 8 9 18 13 9 3 24 10 32 15 8 5 29 15 45 22 17
8 44 24 61 36 17 13 38 23 47 23 8 0 17 3 19 8 2 4 30 20 63 37 33 16 67 34
75 41 30 24 91 54 109 54 10 0 21 7 25 15 3 8 12 15 21 15 8 0 15 4 15 9 0 5
8 11 18 14 9 3 33 14 52 25 19 11 49 26 65 33 17 8 32 17 35 21 3 3 31 20 63
36 31 16 63 34 70 39 6 5 28 16 47 23 19 8 40 19 47 25 31 26 40 32 73 45 19
7 42 18 50 25 8 6 29 17 45 25 17 8 44 24 60 35 17 12 45 27 63 33 18 6 45 20
60 30 15 11 43 27 62 36 19 9 67 35 105 56 39 22 87 47 108 57 20 10 37 21 37
25 0 4 16 14 35 23 36 15 92 42 126 60 10 5 19 13 19 17 0 5 9 8 20 8 11 0 20
5 20 10 0 10 22 21 98 52 17 7 32 16 32 20 0 3 25 19 55 33 30 15 59 33 66 41
6 8 19 14 28 15 9 0 30 9 46 20 17 11 38 22 48 25 9 4 17 9 17 13 0 4 16 13
35 21 19 8 35 17 35 21 0 5 17 15 38 24 20 10 53 26 72 37 19 10 43 22 53 25
9 3 17 9 17 14 0 5 9 9 19 9 10 0 21 6 24 13 3 8 29 26 59 41 29 15 60 31 68
35 8 5 36 19 63 32 26 12 52 28 58 36 6 7 15 13 20 13 5 0 36 18 70 40 34 22
70 40 79 40 10 0 20 6 23 13 2 6 49 34 103 62 55 27 108 58 119 68 11 10 30
20 42 23 13 4 23 10 23 15 0 5 7 9 14 9 8 0 27 11 42 25 15 14 35 25 45 25 11
0 19 5 19 10 0 6 7 10 15 10 7 0 18 6 22 13 4 7 29 23 56 36 26 13 52 30 58
38 6 7 18 13 25 13 8 0 14 5 14 10 0 6 9 10 20 10 11 0 20 4 20 8 0 5 18 17
40 28 22 10 40 22 40 27 0 4 6 7 14 7 7 0 19 6 25 13 6 8 32 25 58 38 27 13
52 29 56 36 4 7 13 13 19 13 5 0 27 13 47 29 20 16 60 41 89 56 29 15 57 36
63 46 5 11 17 19 25 19 9 0 22 6 29 13 31 27 44 37 51 37 4 0 31 20 60 45 28
25 57 45 63 45 11 0 31 32 31 49 0 18 -90 13 -124 -8 -17 -10 -53 -24 -81 -31
-27 -7 -57 -19 -66 -27 -8 -7 -23 -13 -32 -13 -9 0 -19 -4 -22 -10 -3 -5 -17
-10 -29 -10 -13 0 -29 -7 -36 -15 -7 -8 -23 -15 -36 -15 -12 0 -26 -4 -29 -10
-3 -5 -17 -10 -29 -10 -13 0 -29 -7 -36 -15 -7 -8 -21 -15 -31 -15 -10 0 -21
-4 -24 -10 -3 -5 -17 -10 -29 -10 -13 0 -29 -7 -36 -15 -7 -8 -17 -15 -22 -15
-5 0 -28 -9 -50 -20 -23 -11 -47 -20 -54 -20 -6 0 -17 -7 -24 -15 -7 -8 -23
-15 -36 -15 -12 0 -26 -4 -29 -10 -3 -5 -17 -10 -30 -10 -12 0 -25 -7 -29 -15
-3 -8 -12 -15 -19 -15 -8 0 -44 -16 -81 -35 -37 -19 -73 -35 -80 -35 -7 0 -34
-11 -60 -25 -26 -14 -56 -25 -67 -25 -10 0 -19 -4 -19 -10 0 -5 -6 -10 -14
-10 -7 0 -19 -7 -26 -15 -7 -8 -23 -15 -36 -15 -13 0 -24 -4 -24 -10 0 -5 -11
-10 -24 -10 -13 0 -29 -7 -36 -15 -7 -8 -23 -15 -35 -15 -13 0 -25 -3 -27 -7
-5 -12 -111 -63 -131 -63 -9 0 -17 -4 -17 -10 0 -5 -6 -10 -14 -10 -17 0 -80
-32 -84 -42 -2 -5 -14 -8 -27 -8 -12 0 -28 -7 -35 -15 -7 -8 -21 -15 -31 -15
-10 0 -21 -4 -24 -10 -3 -5 -15 -10 -25 -10 -10 0 -20 -3 -22 -7 -5 -11 -67
-43 -84 -43 -16 0 -56 -20 -65 -34 -8 -10 -77 -36 -96 -36 -7 0 -24 -11 -39
-25 -15 -14 -34 -25 -43 -25 -10 0 -48 -16 -85 -35 -38 -19 -77 -35 -86 -35
-10 0 -20 -6 -23 -13 -3 -7 -23 -19 -46 -27 -23 -7 -46 -19 -52 -27 -6 -7 -22
-13 -35 -13 -13 0 -24 -3 -24 -7 0 -9 -48 -33 -66 -33 -6 0 -17 -7 -24 -15 -7
-8 -23 -15 -36 -15 -13 0 -24 -4 -24 -10 0 -5 -9 -10 -19 -10 -10 0 -21 -7
-25 -15 -3 -8 -14 -15 -25 -15 -19 0 -104 -42 -125 -61 -6 -5 -18 -9 -28 -9
-22 0 -60 -20 -71 -37 -4 -7 -19 -13 -32 -13 -13 0 -27 -4 -30 -10 -3 -5 -15
-10 -26 -10 -10 0 -19 -4 -19 -8 0 -5 -19 -16 -42 -26 -89 -37 -108 -47 -108
-56 0 -6 -11 -10 -24 -10 -14 0 -28 -4 -31 -10 -3 -5 -14 -10 -25 -10 -10 0
-20 -7 -24 -15 -3 -8 -14 -15 -25 -15 -11 0 -23 -4 -26 -10 -3 -5 -15 -10 -25
-10 -10 0 -20 -3 -22 -7 -3 -8 -33 -23 -110 -57 -20 -9 -40 -21 -43 -26 -3 -6
-17 -10 -31 -10 -13 0 -24 -4 -24 -10 0 -5 -7 -10 -16 -10 -8 0 -22 -7 -30
-15 -9 -8 -24 -15 -35 -15 -10 0 -19 -4 -19 -10 0 -5 -6 -10 -13 -10 -18 0
-75 -28 -82 -41 -4 -5 -17 -9 -31 -9 -13 0 -24 -4 -24 -10 0 -5 -9 -10 -19
-10 -10 0 -21 -7 -25 -15 -3 -8 -14 -15 -25 -15 -11 0 -23 -4 -26 -10 -3 -5
-15 -10 -25 -10 -10 0 -20 -3 -22 -7 -1 -5 -21 -16 -43 -27 -22 -10 -48 -22
-57 -27 -10 -5 -24 -9 -32 -9 -8 0 -16 -7 -20 -15 -3 -8 -14 -15 -25 -15 -11
0 -23 -4 -26 -10 -3 -5 -14 -10 -24 -10 -10 0 -24 -7 -31 -15 -7 -8 -21 -15
-31 -15 -11 0 -19 -3 -19 -7 0 -11 -50 -33 -71 -33 -10 0 -22 -6 -26 -12 -11
-18 -49 -38 -72 -38 -10 0 -24 -7 -31 -15 -7 -8 -17 -15 -22 -15 -14 0 -163
-73 -166 -82 -2 -4 -14 -8 -27 -8 -13 0 -27 -4 -30 -10 -3 -5 -23 -17 -43 -26
-20 -8 -44 -20 -52 -25 -8 -5 -26 -14 -40 -20 -14 -6 -38 -16 -55 -24 -16 -7
-37 -16 -45 -19 -8 -3 -28 -15 -45 -25 -16 -11 -40 -20 -52 -20 -13 -1 -23 -5
-23 -10 0 -12 -57 -41 -81 -41 -9 0 -19 -3 -21 -7 -1 -5 -28 -20 -58 -36 -89
-45 -114 -36 -71 27 15 22 36 59 46 81 10 22 26 47 37 56 10 9 18 21 18 26 0
18 29 69 50 88 11 10 20 24 20 32 0 14 18 50 35 69 6 6 22 33 35 60 14 27 27
51 30 54 8 8 30 43 46 75 8 17 24 44 34 60 11 17 26 42 32 58 7 15 15 27 19
27 4 0 10 11 13 25 4 14 11 25 16 25 6 0 10 8 10 18 0 10 9 28 20 40 11 12 20
25 20 30 0 5 7 15 15 22 8 7 15 21 15 31 0 11 5 19 10 19 6 0 10 7 10 15 0 9
11 27 25 41 14 14 25 29 25 34 0 12 37 78 61 109 11 13 19 30 19 37 0 7 6 19
13 26 16 18 41 62 68 121 12 26 25 47 29 47 4 0 10 8 14 18 7 22 42 82 56 96
5 5 10 18 10 28 0 10 5 18 10 18 6 0 10 6 10 14 0 7 11 25 25 40 14 15 25 33
25 41 0 8 5 17 10 20 6 3 10 13 10 21 0 8 4 20 10 27 47 58 60 77 61 88 0 8 9
28 19 44 10 17 31 53 46 80 14 28 30 52 33 55 4 3 13 21 21 40 7 19 23 46 35
60 11 14 26 36 32 50 6 14 18 42 27 63 10 20 21 37 25 37 5 0 21 25 36 55 14
30 31 55 36 55 5 0 9 8 9 18 0 9 9 28 20 42 11 14 20 31 20 38 0 7 7 15 15 18
8 3 17 15 21 27 10 32 74 118 121 164 24 22 43 48 43 57 0 9 7 19 15 22 8 4
15 18 15 33 0 14 9 37 20 51 11 14 20 30 20 37 0 7 7 16 16 21 14 8 14 12 3
30 -11 18 -9 24 19 56 24 28 32 46 32 75 0 22 6 44 15 51 8 7 15 26 15 42 0
31 21 58 60 74 14 6 43 21 65 32 22 12 65 32 95 47 30 14 62 30 70 35 25 16
120 60 129 60 5 0 11 3 13 8 5 11 93 52 112 52 9 0 16 4 16 9 0 11 56 41 77
41 7 0 13 5 13 10 0 6 11 10 25 10 14 0 25 4 25 9 0 11 56 41 77 41 7 0 13 5
13 10 0 6 9 10 19 10 11 0 22 4 25 9 7 10 105 61 118 61 5 0 25 10 46 23 20
13 53 29 72 37 19 8 37 16 40 19 10 12 98 51 113 51 9 0 20 6 24 13 10 16 49
37 68 37 8 0 15 5 15 10 0 6 11 10 25 10 14 0 25 4 25 9 0 11 56 41 77 41 7 0
13 5 13 10 0 6 11 10 25 10 14 0 25 4 25 8 0 4 26 21 58 36 31 16 73 37 92 47
19 10 51 25 70 34 19 9 44 22 55 27 11 6 43 22 70 35 28 13 59 29 70 36 11 6
45 24 75 41 30 16 82 44 115 63 33 18 68 36 78 39 9 4 17 10 17 15 0 5 11 9
25 9 14 0 25 5 25 10 0 6 9 10 20 10 11 0 20 3 20 8 0 11 124 82 144 82 8 0
16 7 20 15 3 8 30 26 59 40 30 13 60 31 67 40 7 8 18 15 25 15 7 0 23 10 37
23 13 12 37 28 54 36 49 23 57 27 108 55 64 36 76 49 76 85 0 30 -21 43 -35
22z m-3845 -2094 c0 -19 -30 -77 -40 -77 -4 0 -10 -8 -13 -17 -4 -10 -16 -34
-29 -54 -13 -19 -38 -61 -56 -91 -18 -31 -40 -62 -47 -68 -8 -7 -15 -18 -15
-24 0 -6 -16 -35 -35 -63 -19 -29 -35 -56 -35 -60 0 -5 -11 -20 -25 -35 -14
-15 -25 -32 -25 -39 0 -6 -16 -34 -35 -60 -19 -27 -35 -54 -35 -59 0 -6 -4
-10 -8 -10 -5 0 -14 -16 -22 -35 -8 -19 -17 -35 -21 -35 -4 0 -14 -12 -22 -27
-34 -66 -46 -86 -54 -92 -5 -3 -21 -32 -36 -63 -15 -32 -31 -58 -35 -58 -5 0
-16 -19 -26 -42 -10 -24 -29 -54 -41 -68 -12 -14 -29 -41 -38 -61 -9 -19 -25
-43 -37 -54 -11 -10 -20 -24 -20 -32 0 -16 -44 -88 -60 -98 -5 -3 -10 -13 -10
-21 0 -7 -16 -36 -35 -63 -19 -26 -35 -52 -35 -55 0 -4 -13 -27 -30 -51 -16
-24 -30 -47 -30 -51 0 -4 -16 -31 -35 -60 -19 -29 -35 -57 -35 -62 0 -5 -9
-17 -20 -27 -12 -11 -28 -35 -37 -54 -21 -44 -65 -115 -75 -119 -5 -2 -8 -12
-8 -21 0 -10 -9 -26 -20 -36 -11 -10 -20 -24 -20 -30 0 -7 -7 -18 -15 -25 -8
-7 -15 -20 -15 -30 0 -10 -7 -24 -16 -31 -9 -7 -20 -22 -25 -34 -11 -22 -21
-40 -62 -102 -15 -24 -27 -46 -27 -49 0 -4 -16 -31 -35 -60 -19 -29 -35 -56
-35 -60 0 -3 -16 -29 -35 -55 -19 -27 -35 -56 -35 -64 0 -8 -4 -15 -8 -15 -5
0 -16 -16 -25 -35 -9 -19 -21 -35 -27 -35 -5 0 -10 -11 -10 -25 0 -14 -3 -25
-8 -25 -4 0 -16 -16 -26 -35 -11 -19 -23 -35 -28 -35 -4 0 -8 -7 -8 -16 0 -9
-14 -36 -30 -61 -17 -25 -42 -67 -56 -94 -13 -27 -28 -49 -32 -49 -4 0 -14
-17 -21 -37 -7 -21 -23 -49 -35 -63 -27 -32 -46 -66 -46 -83 0 -8 -9 -22 -21
-33 -11 -10 -31 -41 -44 -70 -13 -28 -29 -57 -37 -65 -8 -8 -26 -40 -42 -71
-15 -32 -31 -58 -36 -58 -4 0 -13 -14 -19 -31 -9 -27 -36 -75 -98 -174 -7 -11
-20 -35 -29 -52 -9 -18 -20 -33 -25 -33 -5 0 -9 -9 -9 -20 0 -11 -7 -23 -15
-26 -8 -4 -15 -12 -15 -20 0 -13 -45 -92 -59 -104 -12 -10 -31 -50 -31 -64 0
-8 -11 -23 -25 -34 -14 -11 -25 -27 -25 -35 0 -9 -4 -19 -10 -22 -5 -3 -10
-13 -10 -22 0 -9 -11 -30 -23 -47 -13 -17 -32 -49 -42 -71 -10 -22 -24 -47
-31 -55 -16 -20 -73 -120 -80 -142 -4 -10 -10 -18 -15 -18 -5 0 -9 -6 -9 -14
0 -7 -11 -25 -25 -40 -14 -15 -25 -36 -25 -47 0 -10 -4 -19 -10 -19 -5 0 -10
-7 -10 -17 0 -9 -11 -30 -24 -48 -34 -44 -66 -103 -66 -120 0 -8 -6 -18 -13
-22 -6 -4 -22 -28 -35 -53 -49 -95 -91 -165 -101 -168 -6 -2 -11 -9 -11 -16 0
-20 -49 -112 -70 -131 -11 -10 -20 -26 -20 -37 0 -10 -4 -18 -10 -18 -5 0 -10
-9 -10 -19 0 -11 -4 -22 -9 -26 -6 -3 -22 -30 -36 -60 -15 -30 -33 -59 -41
-66 -8 -6 -14 -18 -14 -25 0 -8 -4 -14 -10 -14 -5 0 -10 -8 -10 -17 0 -10 -10
-34 -22 -53 -43 -67 -47 -75 -53 -90 -4 -8 -10 -22 -15 -30 -5 -8 -23 -42 -39
-75 -16 -33 -39 -70 -50 -82 -12 -12 -21 -28 -22 -35 0 -7 -13 -35 -29 -63
-15 -27 -40 -74 -56 -103 -15 -30 -33 -56 -41 -59 -7 -3 -13 -13 -13 -23 0
-18 -29 -77 -96 -193 -19 -32 -34 -62 -34 -68 0 -5 -4 -9 -10 -9 -5 0 -10 -7
-10 -15 0 -9 -11 -33 -25 -55 -14 -22 -25 -46 -25 -55 0 -8 -4 -15 -10 -15 -5
0 -10 -7 -10 -15 0 -9 -16 -41 -35 -71 -19 -30 -35 -60 -35 -67 0 -8 -10 -23
-22 -34 -30 -27 -60 -16 -78 29 -8 18 -20 37 -27 41 -7 4 -13 17 -13 27 0 11
-4 20 -10 20 -5 0 -10 9 -10 19 0 11 -4 23 -10 26 -5 3 -10 14 -10 25 0 10 -6
20 -12 23 -7 2 -26 29 -41 58 -16 30 -41 77 -57 104 -15 28 -29 57 -29 66 -1
9 -8 23 -17 30 -16 13 -35 47 -89 159 -15 30 -33 62 -40 70 -20 23 -55 89 -55
104 0 8 -7 16 -15 20 -8 3 -15 15 -15 26 0 11 -4 20 -8 20 -5 0 -14 16 -22 35
-8 19 -16 35 -20 35 -5 0 -19 26 -54 100 -9 19 -34 62 -56 95 -21 33 -39 68
-39 78 -1 9 -5 17 -10 17 -5 0 -14 14 -20 32 -6 17 -17 39 -25 47 -21 24 -56
90 -56 106 0 8 -11 22 -25 31 -14 9 -25 24 -25 33 0 9 -20 43 -45 76 -51 67
-58 113 -25 155 11 14 20 31 20 38 0 7 7 15 15 18 8 4 15 17 15 30 0 13 5 24
10 24 6 0 10 7 10 15 0 14 26 62 40 75 3 3 11 16 18 30 7 14 21 39 32 55 11
17 22 37 26 45 9 25 53 111 89 175 18 33 47 87 64 120 17 33 42 78 56 100 14
22 30 50 35 63 5 12 14 22 20 22 5 0 10 11 10 25 0 14 5 25 10 25 6 0 10 6 10
14 0 16 25 66 37 75 5 3 21 32 36 64 15 31 31 57 36 57 4 0 8 6 8 13 0 18 41
105 54 112 5 4 21 30 35 58 14 29 33 66 42 82 10 17 24 46 32 65 8 19 20 40
26 45 17 14 54 83 54 100 0 8 7 15 15 15 9 0 15 9 15 25 0 14 5 25 10 25 6 0
10 6 10 14 0 17 25 67 38 75 5 3 21 31 35 61 15 30 33 66 41 80 7 14 22 42 32
63 11 21 27 45 37 54 9 9 17 23 18 32 0 9 9 30 19 46 10 17 31 55 46 85 16 30
38 69 51 86 13 17 23 36 23 42 0 7 5 12 10 12 6 0 10 6 10 14 0 15 55 122 75
146 7 8 30 51 51 95 21 44 47 89 56 99 10 11 18 26 18 33 0 8 7 16 15 19 8 4
15 12 15 20 0 8 4 22 9 32 5 9 17 34 27 55 10 20 21 37 25 37 3 0 16 21 29 48
35 73 53 107 60 112 4 3 19 29 34 58 14 28 31 52 36 52 6 0 10 9 10 20 0 11 9
29 20 40 11 11 20 23 20 27 0 14 73 158 82 161 4 2 8 11 8 21 0 22 51 71 73
71 9 0 17 4 17 10 0 5 11 12 25 16 14 3 25 10 25 15 0 5 8 9 18 10 9 0 31 9
47 19 17 11 46 26 65 35 38 18 96 47 139 69 14 7 49 25 76 38 28 14 126 64
218 112 93 47 175 86 182 86 7 0 15 4 17 9 2 5 39 26 83 48 44 22 89 45 100
51 11 6 70 35 130 65 61 30 130 65 155 77 25 13 56 28 70 34 14 6 27 14 30 17
9 10 73 39 87 39 7 0 13 5 13 10 0 6 9 10 19 10 11 0 22 4 26 9 7 13 64 41 82
41 7 0 13 5 13 10 0 6 6 10 14 10 7 0 19 7 26 15 7 8 21 15 31 15 11 0 19 5
19 10 0 6 8 10 18 11 9 0 31 9 47 20 17 10 41 24 55 29 14 6 65 31 114 56 49
24 95 44 102 44 7 0 14 4 16 8 4 10 108 62 124 62 6 0 14 7 18 15 3 8 15 15
26 15 11 0 20 5 20 10 0 6 6 10 13 10 18 0 75 28 82 41 4 5 15 9 26 9 10 0 19
5 19 10 0 6 8 10 18 11 9 0 31 9 47 19 17 11 45 26 63 35 72 34 101 49 192 96
97 50 130 59 130 36z m-3972 -1998 c3 -18 -46 -132 -59 -137 -5 -2 -9 -9 -9
-16 0 -16 -52 -120 -62 -124 -4 -2 -8 -10 -8 -17 0 -17 -50 -109 -62 -113 -4
-2 -8 -11 -9 -20 0 -9 -14 -37 -30 -62 -16 -25 -32 -53 -35 -62 -4 -10 -10
-18 -15 -18 -5 0 -9 -9 -9 -21 0 -11 -11 -37 -25 -57 -14 -20 -25 -40 -25 -45
0 -11 -33 -78 -80 -162 -22 -38 -47 -86 -57 -105 -10 -19 -21 -36 -25 -38 -5
-2 -8 -12 -8 -23 0 -11 -7 -22 -15 -25 -8 -4 -15 -12 -15 -18 0 -7 -9 -31 -20
-54 -11 -22 -20 -45 -20 -50 0 -6 -7 -12 -15 -16 -8 -3 -15 -11 -15 -19 0 -20
-50 -117 -61 -117 -5 0 -9 -5 -9 -12 0 -13 -31 -76 -60 -123 -10 -16 -19 -38
-19 -47 -1 -10 -5 -18 -11 -18 -5 0 -10 -8 -10 -19 0 -10 -7 -24 -15 -31 -8
-7 -15 -19 -15 -26 0 -8 -4 -14 -10 -14 -5 0 -10 -11 -10 -25 0 -14 -4 -25
-10 -25 -5 0 -10 -6 -10 -14 0 -8 -6 -21 -13 -28 -7 -7 -26 -40 -42 -72 -45
-89 -49 -96 -57 -96 -5 0 -8 -6 -8 -13 0 -21 -30 -77 -41 -77 -5 0 -9 -8 -9
-18 0 -10 -4 -22 -9 -28 -5 -5 -14 -26 -21 -46 -6 -21 -15 -38 -19 -38 -4 0
-13 -17 -20 -37 -8 -21 -28 -60 -45 -88 -18 -27 -40 -66 -49 -85 -10 -19 -26
-48 -37 -65 -10 -16 -19 -38 -19 -47 -1 -10 -5 -18 -11 -18 -5 0 -10 -9 -10
-20 0 -11 -7 -23 -15 -26 -8 -4 -15 -12 -15 -18 0 -12 -19 -52 -92 -186 -22
-41 -49 -93 -59 -115 -11 -22 -24 -47 -29 -55 -5 -8 -21 -40 -35 -70 -14 -30
-30 -62 -35 -70 -5 -8 -17 -31 -27 -50 -9 -19 -31 -57 -47 -85 -17 -27 -45
-77 -61 -110 -17 -33 -33 -61 -37 -63 -5 -2 -8 -10 -8 -18 0 -7 -10 -30 -21
-51 -12 -21 -51 -94 -86 -163 -36 -69 -71 -132 -79 -141 -8 -8 -14 -20 -14
-25 0 -15 -50 -113 -61 -120 -5 -3 -9 -14 -9 -25 0 -10 -4 -19 -10 -19 -5 0
-10 -6 -10 -14 0 -18 -32 -76 -42 -76 -5 0 -8 -7 -8 -14 0 -8 -10 -34 -23 -58
-25 -45 -79 -145 -96 -175 -6 -10 -19 -36 -29 -58 -26 -55 -71 -146 -83 -167
-9 -17 -29 -55 -119 -223 -23 -44 -46 -81 -51 -83 -5 -2 -9 -12 -9 -23 0 -10
-4 -19 -10 -19 -5 0 -10 -8 -11 -17 0 -10 -9 -31 -20 -48 -11 -16 -22 -38 -25
-47 -8 -22 -98 -200 -149 -293 -21 -38 -54 -100 -73 -137 -19 -38 -38 -68 -43
-68 -5 0 -9 -11 -9 -25 0 -14 -4 -25 -10 -25 -5 0 -10 -6 -10 -13 0 -21 -30
-77 -41 -77 -5 0 -9 -11 -9 -25 0 -14 -4 -25 -10 -25 -5 0 -10 -7 -10 -15 0
-19 -21 -58 -37 -68 -7 -4 -13 -14 -13 -22 0 -21 -42 -115 -52 -115 -4 0 -8
-4 -8 -10 0 -10 -44 -104 -60 -130 -5 -8 -21 -41 -35 -72 -14 -31 -30 -60 -35
-63 -6 -3 -10 -15 -10 -26 0 -10 -4 -19 -10 -19 -5 0 -10 -9 -10 -20 0 -14 -7
-20 -21 -20 -21 0 -21 1 -14 218 4 119 11 227 16 240 5 13 9 71 9 128 0 66 5
113 13 127 11 21 20 127 33 397 3 69 10 129 15 135 5 5 9 64 9 131 0 96 3 124
15 134 12 10 15 38 15 136 0 71 4 125 10 129 6 4 10 60 10 135 0 75 4 131 10
135 6 4 10 56 10 124 0 88 4 122 15 137 11 14 14 50 15 144 0 70 4 130 9 135
6 6 12 69 15 140 4 72 9 187 12 257 4 93 9 130 20 138 11 10 14 41 14 141 0
74 4 130 10 134 6 4 10 60 10 135 0 75 4 131 10 135 6 4 10 58 10 129 0 96 3
126 14 136 11 8 16 45 20 143 3 73 8 168 11 212 3 44 9 155 14 247 7 125 13
173 25 190 9 12 16 38 16 58 0 33 4 37 58 63 31 15 65 27 74 27 9 0 18 4 20 8
4 11 108 62 125 62 7 0 13 4 13 9 0 5 11 12 25 15 14 4 25 11 25 16 0 6 6 10
13 10 17 0 121 51 125 62 2 4 9 8 16 8 7 0 26 6 42 14 16 8 56 26 89 41 90 40
208 95 227 106 10 5 25 9 33 9 8 0 15 4 15 9 0 11 56 41 77 41 7 0 13 5 13 10
0 6 11 10 24 10 13 0 26 7 30 15 3 8 15 15 26 15 11 0 20 5 20 10 0 6 8 10 18
11 9 0 31 9 47 20 17 10 37 21 45 25 8 3 24 9 35 14 34 13 178 81 205 97 44
24 132 63 145 63 7 0 15 7 19 15 3 8 12 15 20 15 9 0 31 9 51 20 20 11 42 20
49 20 8 0 16 7 20 15 3 8 15 15 26 15 11 0 20 5 20 10 0 6 8 10 18 11 9 0 31
9 47 19 17 11 44 26 60 33 70 33 102 49 135 66 19 10 76 37 125 61 185 87 240
113 255 121 8 5 40 20 70 34 30 14 62 30 70 35 8 5 31 17 50 26 83 39 97 46
125 64 35 22 58 21 63 -1z m-1168 -3709 c7 -22 22 -47 32 -57 10 -9 28 -35 39
-57 11 -23 36 -68 54 -101 19 -33 39 -69 44 -80 5 -12 16 -27 25 -34 9 -7 16
-22 16 -32 0 -11 5 -19 10 -19 6 0 15 -10 20 -22 5 -13 21 -41 34 -63 14 -22
37 -62 52 -90 14 -27 33 -54 40 -58 8 -4 14 -15 14 -24 0 -8 14 -35 30 -60 26
-39 51 -81 95 -164 5 -11 13 -19 17 -19 5 0 8 -10 8 -23 0 -12 11 -31 25 -41
14 -10 25 -27 25 -37 0 -11 5 -19 10 -19 6 0 10 -8 10 -18 0 -10 8 -27 19 -38
10 -11 31 -42 46 -70 15 -27 38 -63 51 -81 13 -17 24 -37 24 -44 0 -6 15 -32
33 -58 18 -25 39 -60 46 -77 15 -39 5 -84 -19 -84 -11 0 -22 -4 -25 -10 -3 -5
-23 -17 -43 -26 -20 -9 -106 -50 -190 -90 -84 -41 -161 -74 -172 -74 -11 0
-20 -4 -20 -9 0 -11 -56 -41 -77 -41 -7 0 -13 -4 -13 -10 0 -5 -11 -10 -25
-10 -14 0 -25 -4 -25 -9 0 -11 -56 -41 -77 -41 -7 0 -13 -4 -13 -10 0 -5 -9
-10 -19 -10 -11 0 -22 -4 -25 -9 -7 -10 -105 -61 -118 -61 -5 0 -25 -10 -46
-23 -20 -13 -53 -29 -72 -37 -19 -8 -37 -17 -40 -20 -4 -6 -62 -34 -110 -54
-8 -3 -28 -15 -45 -25 -16 -11 -38 -20 -47 -20 -10 -1 -18 -5 -18 -11 0 -5
-11 -10 -25 -10 -14 0 -25 -4 -25 -9 0 -11 -56 -41 -77 -41 -7 0 -13 -4 -13
-10 0 -5 -7 -10 -15 -10 -9 0 -33 -11 -55 -25 -22 -14 -46 -25 -55 -25 -8 0
-15 -4 -15 -10 0 -5 -7 -10 -15 -10 -15 0 -55 -19 -65 -31 -3 -3 -23 -14 -45
-23 -22 -10 -49 -23 -60 -29 -54 -30 -231 -117 -238 -117 -4 0 -25 -11 -47
-25 -22 -14 -46 -25 -55 -25 -8 0 -15 -4 -15 -10 0 -5 -6 -10 -13 -10 -18 0
-75 -28 -82 -41 -4 -5 -15 -9 -26 -9 -10 0 -19 -4 -19 -10 0 -5 -6 -10 -13
-10 -18 0 -75 -28 -82 -41 -9 -14 -41 -11 -54 5 -8 10 -8 16 3 25 8 7 26 36
41 66 14 30 31 55 36 55 5 0 9 6 9 14 0 21 43 98 58 103 6 3 12 11 12 19 0 7
9 29 20 49 11 20 20 42 20 50 0 8 6 18 13 22 12 8 27 33 80 138 17 33 38 71
48 85 31 46 59 100 59 115 0 8 4 15 9 15 5 0 24 29 42 65 18 36 41 74 51 84
10 11 18 29 18 41 0 11 5 20 10 20 6 0 10 8 10 19 0 10 7 24 15 31 8 7 15 19
15 26 0 8 4 14 8 14 4 0 13 12 20 28 7 15 23 47 37 72 14 25 29 57 34 73 6 15
15 27 20 27 6 0 11 6 11 14 0 7 9 25 20 39 11 14 20 32 20 41 0 9 7 19 15 22
8 4 15 12 15 18 0 15 37 90 65 131 12 17 34 56 50 88 16 31 33 57 37 57 4 0 8
8 8 18 0 23 28 82 40 82 4 0 17 21 29 48 31 67 83 163 106 197 12 17 27 44 34
60 7 17 17 37 22 45 5 8 16 31 25 50 10 19 32 56 51 83 18 26 33 51 33 55 0
16 52 112 61 112 5 0 9 7 9 16 0 9 13 38 28 63 15 25 36 62 46 81 17 35 33 63
50 88 12 20 50 -19 66 -68z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -1,34 +1,38 @@
import { getLogout } from '@api/auth'
import solidLogo from '@assets/solid.svg'
import { getProfile } from '@api/user'
import fuwareLogo from '@assets/logo-fuware.svg'
import { useSiteContext } from '@context/SiteContext'
import useLanguage from '@hooks/useLanguage'
import {
Avatar,
AvatarBadge,
Button,
Flex,
Spacer,
Text,
notificationService,
} from '@hope-ui/solid'
import { A, useNavigate } from '@solidjs/router'
import { Helpers } from '@utils/helper'
import { Show } from 'solid-js'
import useAuth from '@hooks/useAuth'
import useToast from '@hooks/useToast'
import { A } from '@solidjs/router'
import { IconLogout, IconMenuDeep } from '@tabler/icons-solidjs'
import { Show, onMount } from 'solid-js'
import { css } from 'solid-styled-components'
export default function Header() {
const { store, setAuth } = useSiteContext()
const navigate = useNavigate()
const language = useLanguage()
const { store, setAuth, setUser } = useSiteContext()
const { clickLogOut } = useAuth(setAuth)
const notify = useToast()
onMount(async () => {
try {
const resp = await getProfile()
if (resp.status === 200) {
setUser(resp.data)
}
} catch (error) {
notify.error({
title: 'Get profile fail!',
closable: false,
description: error?.data || 'Can not get user profile!',
})
}
})
const logOut = async () => {
try {
await getLogout()
Helpers.clearCookie()
setAuth({ auth: false, user: null })
navigate('/login', { replace: false })
await clickLogOut()
} catch (error) {
notificationService.show({
console.log({
status: 'danger',
title: 'Logout fail!',
closable: false,
@ -37,41 +41,48 @@ export default function Header() {
}
return (
<header
class={css`
width: 100%;
`}
>
<Flex bgColor="$success7" p="$3">
<A href="/">
<img
src={solidLogo}
class={css`
width: 30px;
`}
alt="Solid logo"
/>
</A>
<Spacer />
<Flex alignItems="center">
<Show when={store.auth}>
<Avatar name={store.userInfo?.name} size="sm">
<AvatarBadge boxSize="1.25em" bg="$success9" />
</Avatar>
<Text size="sm" ml="$2" mr="$5" color="white">
<header>
<div class="flex py-3 px-4 items-center justify-between bg-emerald-500">
<div class="flex items-center justify-end">
<A href="/" class="text-white flex items-center hover:text-white">
<img
src={fuwareLogo}
class={css`
width: 30px;
`}
alt="Fuware logo"
/>
<span class="ml-2 text-2xl">Fuware</span>
</A>
</div>
<Show when={store.auth}>
<div class="flex items-center justify-end">
<div class="avatar hidden lg:block">
<div class="w-9 mask mask-hexagon">
<img
src={`https://ui-avatars.com/api/?name=${store.userInfo?.name}`}
alt="avatar"
/>
</div>
</div>
<span class="mx-3 text-white hidden lg:block">
{store.userInfo?.name}
</Text>
<Button
size="sm"
variant="subtle"
colorScheme="info"
</span>
<button
class="btn btn-ghost btn-sm hidden lg:block"
onClick={logOut}
>
{language.ui.logout}
</Button>
</Show>
</Flex>
</Flex>
<IconLogout size={16} />
</button>
<label
for="nav-menu"
class="btn btn-ghost btn-sm drawer-button pr-0 lg:hidden"
>
<IconMenuDeep size={25} color="white" />
</label>
</div>
</Show>
</div>
</header>
)
}

View File

@ -0,0 +1,75 @@
// import { styled } from 'solid-styled-components'
import { useSiteContext } from '@context/SiteContext'
import useAuth from '@hooks/useAuth'
import useLanguage from '@hooks/useLanguage'
import { A } from '@solidjs/router'
import { IconDashboard, IconLogout, IconTriangle } from '@tabler/icons-solidjs'
import { For, Show } from 'solid-js'
import { Dynamic } from 'solid-js/web'
const language = useLanguage('vi')
const NAVBAR_ITEM = [
{
path: '/dashboard',
icon: IconDashboard,
text: language?.ui.dashboard,
},
]
export default function Navbar() {
const { store, setAuth } = useSiteContext()
const { clickLogOut } = useAuth(setAuth)
const logOut = async () => {
try {
await clickLogOut()
} catch (error) {
console.log({
status: 'danger',
title: 'Logout fail!',
closable: false,
})
}
}
return (
<div class="drawer-side">
<label for="nav-menu" aria-label="close sidebar" class="drawer-overlay" />
<div class="bg-base-200 w-80 min-h-full">
<Show when={store.auth}>
<div class="flex items-center justify-between px-5 pt-5 lg:hidden">
<div class="avatar">
<div class="w-9 mask mask-hexagon">
<img
src={`https://ui-avatars.com/api/?name=${store.userInfo?.name}`}
alt="avatar"
/>
</div>
</div>
<span class="mx-3 line-clamp-1">{store.userInfo?.name}</span>
<button class="btn btn-ghost btn-sm" onClick={logOut}>
<IconLogout size={16} />
</button>
</div>
<div class="divider divider-success mb-0 lg:hidden">
<IconTriangle size={30} />
</div>
</Show>
<ul class="menu p-4 w-80 text-base-content">
<For each={NAVBAR_ITEM}>
{(item) => (
<li>
<A href={item.path}>
<Dynamic component={item.icon} />
{item.text}
</A>
</li>
)}
</For>
</ul>
</div>
</div>
)
}

View File

@ -1,34 +0,0 @@
// import { styled } from 'solid-styled-components'
import useLanguage from '@hooks/useLanguage'
import { Flex, Icon, Text } from '@hope-ui/solid'
import { A } from '@solidjs/router'
import { IconDashboard } from '@tabler/icons-solidjs'
import { For } from 'solid-js'
const language = useLanguage('vi')
const NAVBAR_ITEM = [
{
path: '/dashboard',
icon: IconDashboard,
text: language?.ui.dashboard,
},
]
export default function Navbar() {
return (
<div class="navbar">
<For each={NAVBAR_ITEM}>
{(item) => (
<A href={item.path}>
<Flex padding="$5" alignItems="center">
<Icon as={item.icon} boxSize="$6" mr="$2_5" />
<Text size="lg">{item.text}</Text>
</Flex>
</A>
)}
</For>
</div>
)
}

View File

@ -1 +0,0 @@
export { default } from './Navbar'

View File

@ -0,0 +1,62 @@
import {
IconCircleCheck,
IconFaceIdError,
IconInfoCircle,
IconX,
} from '@tabler/icons-solidjs'
import { Show } from 'solid-js'
import { Dynamic } from 'solid-js/web'
const STATUS = Object.freeze(
new Proxy(
{
success: {
icon: IconCircleCheck,
color: 'text-green-500',
},
error: {
icon: IconFaceIdError,
color: 'text-red-500',
},
info: {
icon: IconInfoCircle,
color: 'text-blue-500',
},
},
{
get: (target, prop) =>
target[prop] ?? { icon: IconInfoCircle, color: 'text-blue-500' },
},
),
)
export default function Notify(props) {
return (
<div class="bg-white border border-slate-300 w-max h-20 shadow-lg rounded-md gap-4 p-4 flex flex-row items-center justify-center">
<section class="w-6 h-full flex flex-col items-center justify-start">
<Dynamic
component={STATUS[props.status].icon}
size={30}
class={STATUS[props.status].color}
/>
</section>
<section class="h-full flex flex-col items-start justify-end gap-1">
<Show when={props.title}>
<h1
class={`text-base font-semibold text-zinc-800 antialiased ${STATUS[props.status].color}`}
>
{props.title}
</h1>
</Show>
<p class="text-sm font-medium text-black antialiased">
{props.description}
</p>
</section>
<Show when={props.onClose}>
<section class="w-5 h-full flex flex-col items-center justify-start">
<IconX size={20} class="cursor-pointer" onclick={props.onClose} />
</section>
</Show>
</div>
)
}

View File

@ -1,4 +1,4 @@
import { LOGIN_KEY, STORE_KEY } from '@utils/enum'
import { STORE_KEY } from '@utils/enum'
import { Helpers } from '@utils/helper'
import { createContext, onMount, useContext } from 'solid-js'
import { createStore, produce } from 'solid-js/store'
@ -12,18 +12,17 @@ export function SiteContextProvider(props) {
})
onMount(() => {
const checkCookie = Helpers.getCookie(LOGIN_KEY)
if (checkCookie) {
const storeData = Helpers.decrypt(localStorage.getItem(STORE_KEY))
if (!storeData) return
setStore(storeData)
} else {
localStorage.removeItem(STORE_KEY)
}
const storeData = Helpers.decrypt(localStorage.getItem(STORE_KEY))
if (!storeData) return
setStore(storeData)
})
const setLocalStore = () => {
localStorage.setItem(STORE_KEY, Helpers.encrypt(store))
if (store.auth) {
localStorage.setItem(STORE_KEY, Helpers.encrypt(store))
} else {
localStorage.removeItem(STORE_KEY)
}
}
const setAuth = ({ auth, user }) => {
@ -36,8 +35,16 @@ export function SiteContextProvider(props) {
setLocalStore()
}
const setUser = (user) => {
setStore(
produce((s) => {
s.userInfo = user
}),
)
}
return (
<SiteContext.Provider value={{ store, setAuth }}>
<SiteContext.Provider value={{ store, setAuth, setUser }}>
{props.children}
</SiteContext.Provider>
)

View File

@ -0,0 +1,41 @@
import { getLogout, postLogin } from '@api/auth'
import { useNavigate } from '@solidjs/router'
import { LOGIN_KEY } from '@utils/enum'
import { Helpers } from '@utils/helper'
export default function useAuth(setAuth) {
const navigate = useNavigate()
const clickLogIn = async (username, password, cbFormReset) => {
const loginData = {
username: username,
password: password,
}
const resp = await postLogin(loginData)
if (resp.status === 200) {
const token = resp.data || {}
if (token) {
const { name, ...rest } = token
setAuth({ auth: true, user: { name } })
localStorage.setItem(LOGIN_KEY, Helpers.encrypt(JSON.stringify(rest)))
}
cbFormReset()
navigate('/', { replace: true })
}
}
const clickLogOut = async () => {
await getLogout()
Helpers.clearStorage()
setAuth({ auth: false, user: null })
navigate('/login', { replace: false })
}
return {
clickLogOut,
clickLogIn,
}
}

View File

@ -0,0 +1,31 @@
import Notify from '@components/Notify'
import toast from 'solid-toast'
export default function useToast() {
const notify = {}
notify.show = ({ status, title, description, closable = false }) => {
return toast.custom((t) => (
<Notify
status={status}
title={title}
description={description}
onClose={closable ? () => toast.dismiss(t.id) : null}
/>
))
}
notify.success = ({ title, description, closable = false }) => {
return notify.show({ status: 'success', title, description, closable })
}
notify.error = ({ title, description, closable = false }) => {
return notify.show({ status: 'error', title, description, closable })
}
notify.info = ({ title, description, closable = false }) => {
return notify.show({ status: 'info', title, description, closable })
}
return notify
}

View File

@ -1,3 +1,7 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;

View File

@ -2,7 +2,7 @@ import Header from '@components/Header'
import Navbar from '@components/Navbar'
import { useSiteContext } from '@context/SiteContext'
import { useNavigate } from '@solidjs/router'
import { onMount, Show } from 'solid-js'
import { onMount } from 'solid-js'
export default function Layout(props) {
const { store } = useSiteContext()
@ -15,16 +15,17 @@ export default function Layout(props) {
})
return (
<main>
<Show when={store.auth}>
<Header />
</Show>
<div id="main-page" class={store.auth ? '' : 'login-page'}>
<Show when={store.auth}>
<div class="layer-top">
<Header />
<div id="main-page">
<div class="drawer lg:drawer-open">
<input id="nav-menu" type="checkbox" class="drawer-toggle" />
<div class="drawer-content">
<main class="main-content p-3">{props.children}</main>
</div>
<Navbar />
</Show>
<div class="main-content">{props.children}</div>
</div>
</div>
</main>
</div>
)
}

View File

@ -1,17 +1,5 @@
import { postLogin } from '@api/auth'
import { useSiteContext } from '@context/SiteContext'
import useLanguage from '@hooks/useLanguage'
import {
Button,
Center,
FormControl,
FormErrorMessage,
FormLabel,
Heading,
Input,
Stack,
notificationService,
} from '@hope-ui/solid'
import { useNavigate } from '@solidjs/router'
import { Field, useFormHandler } from 'solid-form-handler'
import { yupSchema } from 'solid-form-handler/yup'
@ -19,12 +7,18 @@ import { Show, onMount } from 'solid-js'
import { styled } from 'solid-styled-components'
import * as yup from 'yup'
import logo from '@assets/logo-fuware.svg'
import useAuth from '@hooks/useAuth'
import useToast from '@hooks/useToast'
const LoginPage = styled('div')`
width: 100%;
height: 100svh;
display: flex;
padding-left: 15px;
padding-right: 15px;
background: #fff url('/images/bg-login.jpg') no-repeat fixed center;
background-size: cover;
place-items: center;
.login-wrap {
@ -32,11 +26,51 @@ const LoginPage = styled('div')`
max-width: 500px;
min-width: 320px;
margin: 0 auto;
overflow: hidden;
position: relative;
&:after {
content: '';
display: block;
width: 500px;
height: 500px;
border-radius: 15px;
position: absolute;
z-index: 2;
top: -120px;
left: -285px;
background: #10b981;
transform: rotate(45deg);
}
&:before {
content: '';
display: block;
width: 500px;
height: 500px;
border-radius: 15px;
position: absolute;
z-index: 2;
top: -40px;
left: -130px;
background: #ff6600;
transform: rotate(20deg);
}
.card-body {
position: relative;
z-index: 4;
}
.logo {
position: relative;
z-index: 4;
display: block;
width: 40%;
max-width: 150px;
min-width: 100px;
margin: 0 auto;
margin-top: 15px;
}
.login-box {
@ -57,6 +91,8 @@ const language = useLanguage()
export default function Login() {
const { store, setAuth } = useSiteContext()
const navigate = useNavigate()
const { clickLogIn } = useAuth(setAuth)
const notify = useToast()
const formHandler = useFormHandler(yupSchema(loginSchema))
const { formData } = formHandler
@ -70,90 +106,115 @@ export default function Login() {
event.preventDefault()
await formHandler.validateForm()
try {
const loginData = {
username: formData()?.username,
password: formData()?.password,
}
const resp = await postLogin(loginData)
if (resp.status === 200) {
const user = resp?.data || {}
setAuth({ auth: true, user })
formHandler.resetForm()
navigate('/', { replace: true })
}
const { username, password } = formData()
await clickLogIn(username, password, formHandler.resetForm)
notify.success({
title: 'Login success!',
description: 'Welcome back!',
closable: true,
})
} catch (error) {
notificationService.show({
status: 'danger',
notify.error({
title: 'Login fail!',
description: error?.data || 'Your username or password input is wrong!',
closable: false,
description: error?.data
? language.message[error.data]
: 'Your username or password input is wrong!',
closable: true,
})
}
}
return (
<LoginPage>
<div class="login-wrap">
<Center width="100%" mb="$10">
<div class="card glass card-compact login-wrap shadow-xl">
<div class="h-44">
<picture class="logo">
<source
srcSet="/images/logo_fuware.png"
type="image/png"
media="(min-width: 600px)"
/>
<img src="/images/logo_fuware.png" alt="logo" />
<source srcSet={logo} type="image/png" media="(min-width: 600px)" />
<img src={logo} alt="logo" />
</picture>
</Center>
<div class="login-box">
</div>
<div class="card-body">
<h1 class="card-title">{language.ui.login}</h1>
<form autoComplete="off" onSubmit={submit}>
<Stack direction="column">
<Center w="100%" mb="$5">
<Heading level="1" size="xl">
{language.ui.login}
</Heading>
</Center>
<Field
mode="input"
name="username"
formHandler={formHandler}
render={(field) => (
<FormControl mb="$3" invalid={field.helpers.error}>
<FormLabel for="username">
{language.ui.username}:
</FormLabel>
<Input id="username" type="text" {...field.props} />
<Show when={field.helpers.error}>
<FormErrorMessage>
<Field
mode="input"
name="username"
formHandler={formHandler}
render={(field) => (
<label class="form-control w-full pb-5">
<label
class="input input-bordered flex items-center gap-2 w-full"
classList={{ 'input-error': field.helpers.error }}
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
fill="currentColor"
class="w-4 h-4 opacity-70"
>
<path d="M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM12.735 14c.618 0 1.093-.561.872-1.139a6.002 6.002 0 0 0-11.215 0c-.22.578.254 1.139.872 1.139h9.47Z" />
</svg>
<input
id="username"
type="text"
class="grow w-full"
placeholder="Username"
{...field.props}
/>
</label>
<Show when={field.helpers.error}>
<div class="label">
<span class="label-text-alt text-red-600">
{field.helpers.errorMessage}
</FormErrorMessage>
</Show>
</FormControl>
)}
/>
<Field
mode="input"
name="password"
formHandler={formHandler}
render={(field) => (
<FormControl mb="$5" invalid={field.helpers.error}>
<FormLabel for="username">
{language.ui.password}:
</FormLabel>
<Input id="password" type="password" {...field.props} />
<Show when={field.helpers.error}>
<FormErrorMessage>
</span>
</div>
</Show>
</label>
)}
/>
<Field
mode="input"
name="password"
formHandler={formHandler}
render={(field) => (
<label class="form-control w-full">
<label
class="input input-bordered flex items-center gap-2 w-full"
classList={{ 'input-error': field.helpers.error }}
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
fill="currentColor"
class="w-4 h-4 opacity-70"
>
<path d="M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM12.735 14c.618 0 1.093-.561.872-1.139a6.002 6.002 0 0 0-11.215 0c-.22.578.254 1.139.872 1.139h9.47Z" />
</svg>
<input
id="password"
type="password"
class="grow w-full"
placeholder="Password"
{...field.props}
/>
</label>
<Show when={field.helpers.error}>
<div class="label">
<span class="label-text-alt text-red-600">
{field.helpers.errorMessage}
</FormErrorMessage>
</Show>
</FormControl>
)}
/>
<Button size="sm" type="submit">
</span>
</div>
</Show>
</label>
)}
/>
<div class="card-actions justify-end mt-5">
<button type="submit" class="btn btn-primary">
{language.ui.login}
</Button>
</Stack>
</button>
</div>
</form>
</div>
</div>

View File

@ -1,5 +1,5 @@
const PRODUCTION = import.meta.env.NODE_ENV === 'production'
// const PRODUCTION = import.meta.env.NODE_ENV === 'production'
export const SECRET_KEY = 'bGV0IGRvIGl0IGZvciBlbmNyeXRo'
export const STORE_KEY = 'dXNlciBsb2dpbiBpbmZv'
export const LOGIN_KEY = PRODUCTION ? import.meta.env.VITE_LOGIN_KEY : 'logcook'
export const LOGIN_KEY = '7fo24CMyIc'

View File

@ -2,6 +2,13 @@ import { AES, enc } from 'crypto-js'
import { LOGIN_KEY, SECRET_KEY, STORE_KEY } from './enum'
export class Helpers {
static setCookie = (cname, cvalue, exdays) => {
const d = new Date()
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000)
let expires = `expires=${d.toUTCString()}`
document.cookie = `${cname}=${cvalue};${expires};path=/`
}
static getCookie = (cname) => {
let name = cname + '='
let ca = document.cookie.split(';')
@ -21,11 +28,16 @@ export class Helpers {
document.cookie = `${cname}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`
}
static clearCookie = () => {
this.deleteCookie(LOGIN_KEY)
static clearStorage = () => {
localStorage.removeItem(LOGIN_KEY)
localStorage.removeItem(STORE_KEY)
}
static checkTokenExpired = (exp) => {
const currentTime = Math.floor(new Date().getTime() / 1000)
return exp < currentTime
}
static checkAuth = () => {
return !!this.getCookie(LOGIN_KEY) && !!localStorage.getItem(STORE_KEY)
}

View File

@ -0,0 +1,10 @@
import daisyui from 'daisyui'
/** @type {import('tailwindcss').Config} */
export default {
content: ['./src/**/*.{js,jsx}'],
theme: {
extend: {},
},
plugins: [daisyui],
}

View File

@ -0,0 +1 @@
from .message_code import *

View File

@ -1,20 +1,76 @@
from fastapi import Depends, HTTPException, Request
from sqlalchemy.orm import Session
from fastapi import Depends, HTTPException, Request, status
from fastapi.security import OAuth2PasswordBearer
from fuware.core.config import get_app_settings
from fuware.db.db_setup import generate_session
from fuware.core import MessageCode
import jwt
from fuware.services.user.user_service import UserService
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/api/auth/token")
oauth2_scheme_soft_fail = OAuth2PasswordBearer(tokenUrl="/api/auth/token", auto_error=False)
ALGORITHM = "HS256"
settings = get_app_settings()
async def get_auth_user(request: Request, db: Session = Depends(generate_session)):
credentials_exception = HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Could not validate credentials",
headers={"WWW-Authenticate": "Bearer"},
)
async def is_logged_in(token: str = Depends(oauth2_scheme_soft_fail)) -> bool:
try:
payload = jwt.decode(token, settings.SECRET, algorithms=[ALGORITHM])
user_id: str = payload.get("sub")
exp: int = payload.get("exp")
if exp is not None:
try:
user_service = UserService()
user = user_service.get_by_id(user_id)
if not user:
raise credentials_exception
if user.is_lock is True:
raise HTTPException(status_code=status.HTTP_423_LOCKED, detail=MessageCode.ACCOUNT_LOCK)
except Exception:
return credentials_exception
return user
except Exception:
raise credentials_exception
async def get_current_user(request: Request, token: str | None = Depends(oauth2_scheme_soft_fail)):
"""verify that user has a valid session"""
session_id = request.cookies.get(settings.COOKIE_KEY)
if not session_id:
raise HTTPException(status_code=401, detail="Unauthorized")
# decrypt_user = decryptString(session_id).split(',')
# db_user = get_user_by_username(db, decrypt_user[0])
# if not db_user:
# raise HTTPException(status_code=403)
# if not verify_password(decrypt_user[1], db_user.password):
# raise HTTPException(status_code=401, detail="Your username or password input is wrong!")
return True
if token is None and settings.COOKIE_KEY in request.cookies:
# Try extract from cookie
token = request.cookies.get(settings.COOKIE_KEY, "")
else:
token = token or ""
try:
payload = jwt.decode(token, settings.SECRET, algorithms=[ALGORITHM])
user_id: str = payload.get("sub")
exp: int = payload.get("exp")
if user_id is None or exp is None:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="credentials have expired",
)
user_service = UserService()
user = user_service.get_by_id(user_id)
if not user:
raise credentials_exception
if user.is_lock is True:
raise HTTPException(status_code=status.HTTP_423_LOCKED, detail=MessageCode.ACCOUNT_LOCK)
return user
except jwt.ExpiredSignatureError:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="credentials have expired",
)
except Exception:
raise credentials_exception

View File

@ -1,8 +1,6 @@
class MessageCode:
class MessageCode():
CREATED_USER: str = 'CREATED_USER'
WRONG_INPUT: str = 'LOGIN_WRONG'
ACCOUNT_LOCK: str = 'USER_LOCK'
def message_code():
return MessageCode()
REFRESH_TOKEN_EXPIRED: str = 'REFRESH_TOKEN_EXPIRED'

View File

@ -1 +1 @@
from .hasher import get_hasher
from .security import *

View File

@ -0,0 +1,46 @@
import secrets
from datetime import datetime, timedelta, timezone
from pathlib import Path
import jwt
from fuware.core.config import get_app_settings
from fuware.core import root_logger
from fuware.core.security.hasher import get_hasher
ALGORITHM = "HS256"
logger = root_logger.get_logger("security")
settings = get_app_settings()
def create_access_token(data: dict, expires_delta: timedelta | None = None) -> str:
settings = get_app_settings()
to_encode = data.copy()
expires_delta = expires_delta or timedelta(minutes=settings.EXP_TOKEN)
expire = datetime.now(timezone.utc) + expires_delta
to_encode["exp"] = expire
return jwt.encode(to_encode, settings.SECRET, algorithm=ALGORITHM)
def create_refresh_token(data: dict) -> str:
return create_access_token(data, expires_delta=timedelta(days=settings.EXP_REFRESH))
def create_file_token(file_path: Path) -> str:
token_data = {"file": str(file_path)}
return create_access_token(token_data, expires_delta=timedelta(minutes=30))
def hash_password(password: str) -> str:
"""Takes in a raw password and hashes it. Used prior to saving a new password to the database."""
return get_hasher().hash(password)
def url_safe_token() -> str:
"""Generates a cryptographic token without embedded data. Used for password reset tokens and invitation tokens"""
return secrets.token_urlsafe(24)
def verify_token(exp: int):
expried = datetime.fromtimestamp(exp / 1e3)
return expried < datetime.now(timezone.utc)

View File

@ -7,7 +7,7 @@ def determine_secrets(production: bool) -> str:
if not production:
return "shh-secret-test-key"
return "oWNhXlfo666JlMHk6UHYxeNB6z_CA2MisDDZJe4N0yc="
return "1d00e664fb3b07aff5a191755ea72f9c4bc85a3f36868308d0b2c417aed3419e"
def determine_cookie(production: bool) -> str:
if not production:
@ -31,6 +31,10 @@ class AppSettings(BaseSettings):
SECRET: str
COOKIE_KEY: str
EXP_TOKEN: int = 30
"""in minutes, default is 30 minutes"""
EXP_REFRESH: int = 7
"""in days, default is 7 days"""
LOG_CONFIG_OVERRIDE: Path | None = None
"""path to custom logging configuration file"""

View File

@ -16,19 +16,5 @@ class User(SqlAlchemyBase):
is_admin: Mapped[bool | None] = mapped_column(Boolean, default=False)
is_lock: Mapped[bool | None] = mapped_column(Boolean, default=False)
session_login = relationship("SessionLogin", back_populates="user", uselist=False)
def __repr__(self):
return f"{self.__class__.__name__}, name: {self.name}, username: {self.username}"
class SessionLogin(SqlAlchemyBase):
__tablename__ = 'session_login'
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
session: Mapped[str] = mapped_column(String, unique=True, index=True, nullable=False)
user_id: Mapped[str] = mapped_column(ForeignKey("users.id"), unique=True, index=True, nullable=False)
user = relationship("User", back_populates="session_login")
def __repr__(self):
return f"{self.__class__.__name__}, session: {self.session}, user_id: {self.user_id}"

View File

@ -1,28 +0,0 @@
from fuware.core.security import get_hasher
hasher = get_hasher()
INITIAL_DATA = {
'users': [
{
'username': 'sam',
'password': hasher.hash('admin'),
'name': 'Sam',
'is_admin': 1,
'is_lock': 0,
},
{
'username': 'sam1',
'password': hasher.hash('admin'),
'name': 'Sam1',
'is_admin': 0,
'is_lock': 1
},
]
}
# This method receives a table, a connection and inserts data to that table.
def initialize_table(target, connection, **kwargs):
tablename = str(target)
if tablename in INITIAL_DATA and len(INITIAL_DATA[tablename]) > 0:
connection.execute(target.insert(), INITIAL_DATA[tablename])

View File

@ -1,16 +1,17 @@
from fuware.core.config import get_app_settings
from fuware.core.security.hasher import get_hasher
from fuware.db.models import SessionLogin, User
from fuware.core.security.security import hash_password
from fuware.db.models import User
from fuware.schemas import UserCreate
from sqlalchemy.orm import Session
from uuid import uuid4
from uuid import UUID
from fuware.schemas.user.user import UserSeeds
settings = get_app_settings()
class RepositoryUsers:
def __init__(self):
self.user = User()
self.sessionLogin = SessionLogin()
def get_all(self, skip: int = 0, limit: int = 100):
return self.user.query.offset(skip).limit(limit).all()
@ -18,10 +19,13 @@ class RepositoryUsers:
def get_by_username(self, username: str):
return self.user.query.filter_by(username=username).first()
def create(self, db: Session, user: UserCreate):
def get_by_id(self, user_id: str):
return self.user.query.filter_by(id=UUID(user_id)).first()
def create(self, db: Session, user: UserCreate | UserSeeds):
try:
hasher = get_hasher()
db_user = User(username=user.username, password=hasher.hash(user.password), name=user.name)
password = getattr(user, "password")
db_user = User(**user.dict(exclude={"password"}), password=hash_password(password))
db.add(db_user)
db.commit()
except Exception:
@ -30,36 +34,3 @@ class RepositoryUsers:
db.refresh(db_user)
return db_user
def get_session_by_user_id(self, user_id: str):
return self.sessionLogin.query.filter_by(user_id=user_id).first()
def create_session(self, db: Session, user_id: str):
try:
bhash = uuid4().hex[:10]
db_ss = SessionLogin(session=bhash,user_id=user_id)
db.add(db_ss)
db.commit()
except Exception:
db.rollback()
raise
db.refresh(db_ss)
return db_ss
def login(self, db: Session, user_id: str):
db_ss = self.get_session_by_user_id(user_id)
if not db_ss:
db_ss = self.create_session(db=db, user_id=user_id)
return db_ss
def logout(self, db: Session, user_ss: str):
print(f"Logout: {user_ss}")
db_ss = self.sessionLogin.query.filter_by(session=user_ss).first()
print(f"db_ss: {db_ss}")
try:
db.delete(db_ss)
db.commit()
except Exception as e:
db.rollback()
raise e

View File

@ -3,7 +3,7 @@ from fuware.core.root_logger import get_logger
from fuware.repos.repository_users import RepositoryUsers
from sqlalchemy.orm import Session
from fuware.schemas.user.user import UserCreate
from fuware.schemas.user import UserSeeds
logger = get_logger("init_users")
@ -15,19 +15,19 @@ def dev_users() -> list[dict]:
"username": "sam",
"password": "admin",
"name": "Sam",
"is_admin": 1,
"is_lock": 0,
"is_admin": True,
"is_lock": False,
},
{
"username": "sam1",
"password": "admin",
"name": "Sam1",
"is_admin": 0,
"is_lock": 1
"is_admin": False,
"is_lock": False,
},
]
def default_users_init(session: Session):
users = RepositoryUsers()
for user in dev_users():
users.create(session, UserCreate(**user))
users.create(session, UserSeeds(**user))

View File

@ -1,7 +1,9 @@
from fastapi import APIRouter
from . import (auth)
from . import (auth, user)
router = APIRouter(prefix='/api')
router.include_router(auth.router)
router.include_router(user.router)

View File

@ -4,4 +4,4 @@ from . import auth
router = APIRouter(prefix='/auth')
router.include_router(auth.public_router)
router.include_router(auth.auth_router)

View File

@ -1,43 +1,70 @@
from typing import Any
from fastapi import APIRouter, Depends, HTTPException, Response, Request
from datetime import datetime, timedelta, timezone
from typing import Annotated, Any
from fastapi import APIRouter, Depends, HTTPException, Response, status
from fastapi.encoders import jsonable_encoder
# from fastapi.encoders import jsonable_encoder
from fastapi.security import OAuth2PasswordRequestForm
from sqlalchemy.orm import Session
from fuware.core.config import get_app_settings
from fuware.core.message_code import message_code
from fuware.core.security.hasher import get_hasher
from fuware.core.dependencies.dependencies import get_current_user
from fuware.core import MessageCode
from fuware.db.db_setup import generate_session
from fuware.schemas import ReturnValue, UserRequest, PrivateUser, UserCreate
from fuware.services import UserService
from fuware.schemas import ReturnValue, UserRequest, LoginResponse, UserCreate, PrivateUser
from fuware.services.user import UserService
public_router = APIRouter(tags=["Users: Authentication"])
auth_router = APIRouter(tags=["Users: Authentication"])
user_service = UserService()
hasher = get_hasher()
settings = get_app_settings()
message = message_code()
@public_router.put('/register')
def register_user(user: UserCreate, db: Session = Depends(generate_session)) -> ReturnValue[Any]:
db_dependency = Annotated[Session, Depends(generate_session)]
current_user_token = Annotated[PrivateUser, Depends(get_current_user)]
@auth_router.post('/token')
async def get_token(form_data: Annotated[OAuth2PasswordRequestForm, Depends()], db: db_dependency):
user = user_service.check_exist(user=UserRequest(username=form_data.username, password=form_data.password))
if not user:
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail=MessageCode.WRONG_INPUT)
token = user_service.get_access_token(user_id=user.id)
return {'access_token': token, 'token_type': 'bearer'}
@auth_router.put('/register')
def register_user(user: UserCreate, db: db_dependency) -> ReturnValue[Any]:
db_user = user_service.get_by_username(username=user.username)
if db_user:
raise HTTPException(status_code=400, detail=message.CREATED_USER)
user_return = user_service.create(db=db, user=user)
return ReturnValue(status=200, data=jsonable_encoder(user_return))
raise HTTPException(status_code=400, detail=MessageCode.CREATED_USER)
user_service.create(db=db, user=user)
return ReturnValue(status=200, data="created")
@public_router.post('/login', response_model=ReturnValue[PrivateUser])
def user_login(user: UserRequest, response: Response, db: Session = Depends(generate_session)) -> ReturnValue[Any]:
@auth_router.post('/login', response_model=ReturnValue[LoginResponse])
def user_login(user: UserRequest, response: Response) -> ReturnValue[Any]:
db_user = user_service.check_exist(user=user)
cookieEncode = user_service.check_login(db=db, user_id=db_user.id)
response.set_cookie(key=settings.COOKIE_KEY, value=cookieEncode, max_age=86400, httponly=True)
return ReturnValue(status=200, data=db_user)
if not db_user:
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail=MessageCode.WRONG_INPUT)
if db_user.is_lock is True:
raise HTTPException(status_code=status.HTTP_423_LOCKED, detail=MessageCode.ACCOUNT_LOCK)
access_token, refresh_token = user_service.generate_token(user_id=db_user.id)
duration_access = datetime.now(timezone.utc) + timedelta(minutes=settings.EXP_TOKEN)
duration_refresh = int(timedelta(days=settings.EXP_REFRESH).total_seconds())
response.set_cookie(
key=settings.COOKIE_KEY,
value=refresh_token,
max_age=duration_refresh,
expires=duration_refresh,
httponly=True,
samesite="strict",
)
return ReturnValue(status=200, data=dict(access_token=access_token, exp=int(duration_access.timestamp()), name=db_user.name))
@public_router.get('/logout', response_model=ReturnValue[Any])
def user_logout(request: Request, response: Response, db: Session = Depends(generate_session)) -> ReturnValue[Any]:
session_id = request.cookies.get(settings.COOKIE_KEY)
if not session_id:
@auth_router.get('/refresh')
def user_check(current_user: current_user_token) -> ReturnValue[Any]:
access_token = user_service.get_access_token(user_id=current_user.id)
duration_access = datetime.now(timezone.utc) + timedelta(minutes=settings.EXP_TOKEN)
return ReturnValue(status=200, data=dict(accessToken=access_token, exp=int(duration_access.timestamp())))
@auth_router.get('/logout')
def user_logout(response: Response, current_user: current_user_token) -> ReturnValue[Any]:
if current_user:
response.delete_cookie(key=settings.COOKIE_KEY)
return ReturnValue(status=200, data='Logged out')
user_service.delete_session(db=db, user_ss=session_id)
response.delete_cookie(key=settings.COOKIE_KEY)
return ReturnValue(status=200, data='Logged out')

View File

@ -0,0 +1,7 @@
from fastapi import APIRouter
from . import user
router = APIRouter(prefix='/user')
router.include_router(user.public_router)

View File

@ -0,0 +1,21 @@
from typing import Annotated, Any
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from fuware.core.config import get_app_settings
from fuware.core.dependencies import is_logged_in
from fuware.db.db_setup import generate_session
from fuware.schemas.common import ReturnValue
from fuware.schemas.user import ProfileResponse
from fuware.services.user import UserService
public_router = APIRouter(tags=["Users: Info"])
user_service = UserService()
settings = get_app_settings()
db_dependency = Annotated[Session, Depends(generate_session)]
current_user_token = Annotated[ProfileResponse, Depends(is_logged_in)]
@public_router.get("/me", response_model=ReturnValue[ProfileResponse])
def get_user(current_user: current_user_token) -> ReturnValue[Any]:
return ReturnValue(status=200, data=current_user)

View File

@ -12,9 +12,12 @@ class UserRequest(UserBase):
password: str = Form(...)
class UserCreate(UserRequest):
password: str = Form(...)
name: str
class UserSeeds(UserCreate):
is_admin: bool
is_lock: bool
class PrivateUser(UserBase):
id: UUID
name: str
@ -23,3 +26,16 @@ class PrivateUser(UserBase):
created_at: datetime
updated_at: datetime
model_config = ConfigDict(from_attributes=True)
class ProfileResponse(UserBase):
name: str
is_admin: bool
is_lock: bool
created_at: datetime
updated_at: datetime
model_config = ConfigDict(from_attributes=True)
class LoginResponse(FuwareModel):
access_token: str
exp: int
name: str

View File

@ -1 +0,0 @@
from .user import *

View File

@ -1,15 +1,11 @@
from fastapi import HTTPException
from sqlalchemy.orm import Session
from fuware.core.message_code import message_code
from fuware.core.security.hasher import get_hasher
from fuware.core.security import create_access_token
from fuware.core.security.security import create_refresh_token
from fuware.repos import RepositoryUsers
from fuware.schemas import UserRequest, UserCreate
from fuware.services._base_service import BaseService
hasher = get_hasher()
message = message_code()
class UserService(BaseService):
def __init__(self):
self.repos = RepositoryUsers()
@ -20,22 +16,24 @@ class UserService(BaseService):
def get_by_username(self, username: str):
return self.repos.get_by_username(username)
def get_by_id(self, user_id: str):
return self.repos.get_by_id(user_id)
def create(self, db: Session, user: UserCreate):
return self.repos.create(db=db, user=user)
def check_exist(self, user: UserRequest):
db_user = self.get_by_username(username=user.username)
if not db_user:
raise HTTPException(status_code=401, detail=message.WRONG_INPUT)
if not hasher.verify(password=user.password, hashed=db_user.password):
raise HTTPException(status_code=401, detail=message.WRONG_INPUT)
if db_user.is_lock is True:
raise HTTPException(status_code=401, detail=message.ACCOUNT_LOCK)
return False
if not get_hasher().verify(password=user.password, hashed=db_user.password):
return False
return db_user
def check_login(self, db: Session, user_id: str):
db_session = self.repos.login(db=db, user_id=user_id)
return db_session.session
def generate_token(self, user_id: str):
access_token = create_access_token(data={"sub": str(user_id)})
refresh_token = create_refresh_token(data={"sub": str(user_id)})
return access_token, refresh_token
def delete_session(self, db: Session, user_ss: str):
self.repos.logout(db=db, user_ss=user_ss)
def get_access_token(self, user_id: str):
return create_access_token(data={"sub": str(user_id)})

33
poetry.lock generated
View File

@ -784,6 +784,23 @@ files = [
{file = "pyhumps-3.8.0.tar.gz", hash = "sha256:498026258f7ee1a8e447c2e28526c0bea9407f9a59c03260aee4bd6c04d681a3"},
]
[[package]]
name = "pyjwt"
version = "2.8.0"
description = "JSON Web Token implementation in Python"
optional = false
python-versions = ">=3.7"
files = [
{file = "PyJWT-2.8.0-py3-none-any.whl", hash = "sha256:59127c392cc44c2da5bb3192169a91f429924e17aff6534d70fdc02ab3e04320"},
{file = "PyJWT-2.8.0.tar.gz", hash = "sha256:57e28d156e3d5c10088e0c68abb90bfac3df82b40a71bd0daa20c65ccd5c23de"},
]
[package.extras]
crypto = ["cryptography (>=3.4.0)"]
dev = ["coverage[toml] (==5.0.4)", "cryptography (>=3.4.0)", "pre-commit", "pytest (>=6.0.0,<7.0.0)", "sphinx (>=4.5.0,<5.0.0)", "sphinx-rtd-theme", "zope.interface"]
docs = ["sphinx (>=4.5.0,<5.0.0)", "sphinx-rtd-theme", "zope.interface"]
tests = ["coverage[toml] (==5.0.4)", "pytest (>=6.0.0,<7.0.0)"]
[[package]]
name = "pylint"
version = "3.1.0"
@ -827,6 +844,20 @@ files = [
[package.extras]
cli = ["click (>=5.0)"]
[[package]]
name = "python-multipart"
version = "0.0.9"
description = "A streaming multipart parser for Python"
optional = false
python-versions = ">=3.8"
files = [
{file = "python_multipart-0.0.9-py3-none-any.whl", hash = "sha256:97ca7b8ea7b05f977dc3849c3ba99d51689822fab725c3703af7c866a0c2b215"},
{file = "python_multipart-0.0.9.tar.gz", hash = "sha256:03f54688c663f1b7977105f021043b0793151e4cb1c1a9d4a11fc13d622c4026"},
]
[package.extras]
dev = ["atomicwrites (==1.4.1)", "attrs (==23.2.0)", "coverage (==7.4.1)", "hatch", "invoke (==2.2.0)", "more-itertools (==10.2.0)", "pbr (==6.0.0)", "pluggy (==1.4.0)", "py (==1.11.0)", "pytest (==8.0.0)", "pytest-cov (==4.1.0)", "pytest-timeout (==2.2.0)", "pyyaml (==6.0.1)", "ruff (==0.2.1)"]
[[package]]
name = "pyyaml"
version = "6.0.1"
@ -1331,4 +1362,4 @@ files = [
[metadata]
lock-version = "2.0"
python-versions = "^3.10"
content-hash = "88c334ca5304e6f095e81628512c132bb419f9ee5bb7e1e278a0b9d5f94b84c5"
content-hash = "4763f2b3b35e1b674b8636d573beb91e38da9e4a2b52634e6c6840dbca49f538"

View File

@ -19,6 +19,8 @@ text-unidecode = "^1.3"
pyhumps = "^3.8.0"
bcrypt = "^4.1.3"
alembic = "^1.13.1"
python-multipart = "^0.0.9"
pyjwt = "^2.8.0"
[tool.poetry.group.dev.dependencies]
ruff = "^0.4.1"