diff --git a/.env.example b/.env.example index e62d195..5afbeb5 100644 --- a/.env.example +++ b/.env.example @@ -16,4 +16,6 @@ MYSQL_DB_NAME=lucid SMTP_HOST=localhost SMTP_PORT=465 SMTP_USERNAME=user -SMTP_PASSWORD=password \ No newline at end of file +SMTP_PASSWORD=password + +ACCESS_ADDRESS=http://localhost:3333 diff --git a/README.md b/README.md index 38572dd..f0bb63e 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,16 @@ yarn run dev |Variable name|Description| |-------------|--------------------------------------------| |`NODE_ENV`|Set to `developement` or `production`.| -Please complete +|`PORT`|Port to listen on.| +|`HOST`|Host to listen on. Should be `0.0.0.0`| +|`APP_KEY`|See AdonisJS documentation| +|`DRIVE_DISK`|| +|`SESSION_DRIVER`|| +|`CACHE_VIEWS`|| +|`DB_CONNECTION`|See supported databases in AdonisJS docs| +|`MYSQL_*`|Configuration for MySQL, required if `DB_CONNECTION=mysql`. See AdonisJS docs| +|`SMTP_*`|SMTP server configuration, see AdonisJS docs. Not used yet| +|`ACCESS_ADDRESS`|URL where the server is reachable. Is used to build the Github redirect URI, and should not end with a `/`| # Contact diff --git a/app/Models/User.ts b/app/Models/User.ts index 255f8d1..b470ea3 100644 --- a/app/Models/User.ts +++ b/app/Models/User.ts @@ -30,9 +30,9 @@ export default class User extends BaseModel { public updatedAt: DateTime @beforeSave() - public static async hashPassword(user: User) { - if (user.$dirty.password) { - user.password = await Hash.make(user.password) + public static async hashPassword(users: User) { + if (users.$dirty.password) { + users.password = await Hash.make(users.password) } } } diff --git a/app/Validators/UsernameValidator.ts b/app/Validators/UsernameValidator.ts index 54aeed2..0ce12ca 100644 --- a/app/Validators/UsernameValidator.ts +++ b/app/Validators/UsernameValidator.ts @@ -13,4 +13,4 @@ export default class UsernameValidator { }) public messages: CustomMessages = {} -} +} \ No newline at end of file diff --git a/database/migrations/1692371621634_users.ts b/database/migrations/1692371621634_users.ts index 3d778be..30d5387 100644 --- a/database/migrations/1692371621634_users.ts +++ b/database/migrations/1692371621634_users.ts @@ -6,8 +6,7 @@ export default class extends BaseSchema { public async up() { this.schema.createTable(this.tableName, (table) => { - table.increments('id') - + table.increments('id'), table.string('username', 128).notNullable().unique() table.string('email', 255).notNullable().unique() table.string('password', 180).notNullable() @@ -24,4 +23,4 @@ export default class extends BaseSchema { public async down() { this.schema.dropTable(this.tableName) } -} +} \ No newline at end of file diff --git a/database/seeders/Apps.ts b/database/seeders/Apps.ts new file mode 100644 index 0000000..b30c9f4 --- /dev/null +++ b/database/seeders/Apps.ts @@ -0,0 +1,16 @@ +import BaseSeeder from '@ioc:Adonis/Lucid/Seeder' +import App, {AppCategory} from 'App/Models/App' + +export default class extends BaseSeeder { + public async run () { + const app = await App.create({ + userId: 1, + name: "test app", + desc: "test app descr", + releases: "0.1.0", + source_url: "https://github.com/paxo-phone/paxo-site", + category: AppCategory.OTHER, + }) + app.save() + } +} \ No newline at end of file diff --git a/database/seeders/User.ts b/database/seeders/User.ts new file mode 100644 index 0000000..cad17c3 --- /dev/null +++ b/database/seeders/User.ts @@ -0,0 +1,9 @@ +import BaseSeeder from '@ioc:Adonis/Lucid/Seeder' +import User from 'App/Models/User' + +export default class extends BaseSeeder { + public async run () { + const user = await User.create({id: 1, username: 'test', email: 'test@example.com', password: 'password', type: 0}); + user.save() + } +} \ No newline at end of file diff --git a/env.ts b/env.ts index bc83c13..f3a933c 100644 --- a/env.ts +++ b/env.ts @@ -23,4 +23,6 @@ export default Env.rules({ SESSION_DRIVER: Env.schema.string(), DRIVE_DISK: Env.schema.enum(['local'] as const), NODE_ENV: Env.schema.enum(['development', 'production', 'test'] as const), + + ACCESS_ADDRESS: Env.schema.string() }) diff --git a/resources/scss/layout/_auth.scss b/resources/scss/layout/_auth.scss new file mode 100644 index 0000000..856c2cb --- /dev/null +++ b/resources/scss/layout/_auth.scss @@ -0,0 +1,91 @@ +.form-div{ + padding-top: 135px; +} + +.h2-form { + font-size: 25px; + color: #39BC9B; + text-align: center; +} + + + +input:not([type=file]), textarea, select { + padding: 2vh; + border: 2px solid darkgray; + border-radius: 0.3rem; + margin: 10px; + +} + +.btn-submit, .btn-account { + font-size: 16px; + margin-top: 1rem; + border-radius: 10px; + padding: 1rem; + font-family: inherit; + color: white; + background-color: #39BC9B; + border: white 2px solid; + text-align: center; +} + +.div-signin-plat { + display: flex; + justify-content: center; +} + +.btn-signin-plat { + font-size: 16px; + margin: 1rem; + border-radius: 10px; + padding: 1.5vh 1.5vh 1.5vh 1.5vh; + font-family: inherit; + color: white; + background-color: #39BC9B; + border: #39BC9B 2px solid; + display: flex; + justify-content: space-around; +} + + + +.btn-submit:hover, +.btn-signin-plat:hover, +.btn-account:hover { + background-color: #89D5C0; + border-color: #89D5C0; +} + +#a-register { + margin: 2%; + color: #89D5C0; + display: flex; + justify-content: center; + +} + +#a-register:hover { + color: #88E3CB; +} + +#btn-oauth { + margin-left: 0; +} + +#username-feedback { + margin: 10px; +} + +.arrow { + border: solid #39BC9B; + border-width: 0 3px 3px 0; + display: inline-block; + padding: 3px; + height: 100px; + align-items: center; +} + .left { + transform: rotate(135deg); + -webkit-transform: rotate(135deg); +} diff --git a/resources/scss/styles.scss b/resources/scss/styles.scss index bca010c..a0e45ec 100644 --- a/resources/scss/styles.scss +++ b/resources/scss/styles.scss @@ -10,12 +10,17 @@ @import 'module/banner'; @import 'module/form'; @import 'module/project'; +@import 'module/apps'; +@import 'module/markdown'; // layout +@import 'layout/auth'; @import 'layout/header'; @import 'layout/block'; @import 'layout/container'; @import 'layout/footer'; +@import 'layout/sidebar'; + // utils @import 'utils/utils'; diff --git a/resources/views/apps/create.edge b/resources/views/apps/create.edge index f392413..20c1204 100644 --- a/resources/views/apps/create.edge +++ b/resources/views/apps/create.edge @@ -1,4 +1,4 @@ -@!layout('base/main-apps') +@!layout('base/main') @section('title') Create App @@ -10,43 +10,40 @@ Create App @endsection @section('content') -@if(category) -

{{ t('ui.marketplace.category.' + category) }}

-@elseif(query) -

{{ t('ui.marketplace.resultsFor', {query}) }}

-@else -

{{ t('ui.marketplace.indexCategory') }}

-@end +
-
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
+

{{ t('ui.marketplace.indexCategory') }}

-@endsection +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+@endsection \ No newline at end of file diff --git a/resources/views/auth/login.edge b/resources/views/auth/login.edge index fcb1ea2..6882e5f 100644 --- a/resources/views/auth/login.edge +++ b/resources/views/auth/login.edge @@ -5,10 +5,12 @@ Log in @endsection @section('content') -
- - - - -
-@endsection \ No newline at end of file +
+

Connectez-vous

+
+ + + +
+
+@endsection diff --git a/resources/views/auth/register.edge b/resources/views/auth/register.edge index 43fa085..09b386d 100644 --- a/resources/views/auth/register.edge +++ b/resources/views/auth/register.edge @@ -5,15 +5,18 @@ Register @endsection @section('content') -
- +
+

Enregistrez-vous

+ + - + - + - + - - + + +
@endsection \ No newline at end of file diff --git a/start/routes.ts b/start/routes.ts index 85edd2e..b2058bf 100644 --- a/start/routes.ts +++ b/start/routes.ts @@ -21,7 +21,6 @@ import Route from '@ioc:Adonis/Core/Route' import User, { UserType } from 'App/Models/User' import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext' - /** * ---------------------------------------------- * Main routes @@ -38,7 +37,6 @@ Route.group(() => { Route.get('tedx', 'RedirectionsController.tedx') }) - /** * ---------------------------------------------- * Tutorials @@ -50,7 +48,7 @@ Route.group(() => { Route.get('/t/:id/view', 'TutorialsController.viewStep').as('tutorials.viewStep') Route.get('/t/:id/end', 'TutorialsController.stepEnd').as('tutorials.stepEnd') }) - .prefix('/tutorials') + .prefix('/tutorials').as('tutorials') // ---------------------------------------------- // Marketplace @@ -74,12 +72,9 @@ Route.group(() => { }).prefix('/apps') .middleware('silentAuth') - -/** - * ---------------------------------------------- - * Auth - * ---------------------------------------------- - */ +// ---------------------------------------------- +// Auth +// ---------------------------------------------- Route.group(() => { Route.get('/register', 'UsersController.register') .as('auth.register') @@ -96,15 +91,23 @@ Route.group(() => { .middleware("auth") }).prefix('/auth') -/** - * ---------------------------------------------- - * Dashboard - * ---------------------------------------------- - */ -Route.get('/dash', 'DashboardController.index') - .middleware('auth') - .as('dash') +// ---------------------------------------------- +// Dashboard +// ---------------------------------------------- +Route.group(() => { + Route.get('/', 'DashboardController.index') + .as('dash') + + Route.get('/profile', 'DashboardController.profile') + .as('dash.profile') + + Route.group(() => { + Route.post('/profile', 'DashboardController.editProfile') + .as('dash.profile.edit') + }).prefix('/edit') +}).prefix('/dashboard') + .middleware('auth') /** * ---------------------------------------------- * Admin panel @@ -161,7 +164,6 @@ if (process.env.NODE_ENV == "development") { }) } - /** * ---------------------------------------------- * Legal @@ -171,5 +173,4 @@ Route.group(() => { Route.get('/', 'LegalController.index').as('legal.index') Route.get('/:slug', 'LegalController.view').as('legal.viewLegalDoc') }) - .prefix('/legal') - + .prefix('/legal').as('legal')