Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth + Apps #3 #76

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ MYSQL_DB_NAME=lucid
SMTP_HOST=localhost
SMTP_PORT=465
SMTP_USERNAME=user
SMTP_PASSWORD=password
SMTP_PASSWORD=password

ACCESS_ADDRESS=http://localhost:3333
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions app/Models/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
2 changes: 1 addition & 1 deletion app/Validators/UsernameValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export default class UsernameValidator {
})

public messages: CustomMessages = {}
}
}
5 changes: 2 additions & 3 deletions database/migrations/1692371621634_users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -24,4 +23,4 @@ export default class extends BaseSchema {
public async down() {
this.schema.dropTable(this.tableName)
}
}
}
16 changes: 16 additions & 0 deletions database/seeders/Apps.ts
Original file line number Diff line number Diff line change
@@ -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()
}
}
9 changes: 9 additions & 0 deletions database/seeders/User.ts
Original file line number Diff line number Diff line change
@@ -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: '[email protected]', password: 'password', type: 0});
user.save()
}
}
2 changes: 2 additions & 0 deletions env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
91 changes: 91 additions & 0 deletions resources/scss/layout/_auth.scss
Original file line number Diff line number Diff line change
@@ -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);
}
5 changes: 5 additions & 0 deletions resources/scss/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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';
75 changes: 36 additions & 39 deletions resources/views/apps/create.edge
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@!layout('base/main-apps')
@!layout('base/main')

@section('title')
Create App
Expand All @@ -10,43 +10,40 @@ Create App
@endsection

@section('content')
@if(category)
<h1 class="search-title">{{ t('ui.marketplace.category.' + category) }}</h1>
@elseif(query)
<h1 class="search-title">{{ t('ui.marketplace.resultsFor', {query}) }}</h1>
@else
<h1 class="search-title">{{ t('ui.marketplace.indexCategory') }}</h1>
@end
<section class="container">

<form>
<div>
<input type='text' name='name' value='name'/>
</div>
<div>
<input type='text' name='desc' value='description'/>
</div>
<div>
<input type='file' name='image' value='image'/>
</div>
<div>
<input type='url' name='source_url' value='source url'/>
</div>
<div>
<input type='url' name='releases' value='release url'/>
</div>
<div>
<select name="categories" multiple>
<option value="productivity">productivity</option>
<option value="utilities">utilities</option>
<option value="communication">communication</option>
<option value="games">games</option>
<option value="multimedia">multimedia</option>
<option value="other">other</option>
</select>
</div>
<div>
<button type="submit">create</button>
</div>
</form>
<h1 class="search-title">{{ t('ui.marketplace.indexCategory') }}</h1>

@endsection
<form>
<div>
<input type='text' name='name' />
</div>
<div>
<input type='text' name='desc' />
</div>
<div>
<input type='file' name='image' />
</div>
<div>
<input type='url' name='source_url' />
</div>
<div>
<input type='url' name='releases' />
</div>
<div>
<select name="categories">
<option value="productivity">productivity</option>
<option value="utilities">utilities</option>
<option value="communication">communication</option>
<option value="games">games</option>
<option value="multimedia">multimedia</option>
<option value="other">other</option>
</select>
</div>
<div>
<button type="submit">create</button>
</div>
</form>

</section>
@endsection
16 changes: 9 additions & 7 deletions resources/views/auth/login.edge
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ Log in
@endsection

@section('content')
<form method="post" enctype="multipart/form-data" style="margin-top: 150px;">
<input type="text" name="login" placeholder="Username / email" required>
<input type="password" name="password" placeholder="Password" required>

<button type="submit" class="btn btn-submit">Log in</button>
</form>
@endsection
<section class="form-div">
<p class="h2-form">Connectez-vous</p>
<form method="post" enctype="multipart/form-data">
<input type="text" name="login" placeholder="Username / email" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit" class="btn btn-submit">Log in</button>
</form>
</section>
@endsection
17 changes: 10 additions & 7 deletions resources/views/auth/register.edge
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ Register
@endsection

@section('content')
<form method="post" enctype="multipart/form-data">
<input type="text" name="username" placeholder="Username" value="" required />
<section class="form-div" style="margin-top: 100px; padding-top:100px">
<p class="h2-form">Enregistrez-vous</p>
<form method="post">
<input type="text" name="username" placeholder="Username" value="" required />

<input type="text" name="email" placeholder="Email" value="" required />
<input type="text" name="email" placeholder="Email" value="" required />

<input type="password" name="password" placeholder="Password" required />
<input type="password" name="password" placeholder="Password" required />

<input type="password" name="password_confirmation" placeholder="Repeat password" required />
<input type="password" name="password_confirmation" placeholder="Repeat password" required />

<button class="btn btn-submit">Register</button>
</form>
<button class="btn btn-submit">Register</button>
</form>
</section>
@endsection
Loading