Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Евгений Положенцев
planner-team-one
Commits
fbf6bc53
Commit
fbf6bc53
authored
Nov 30, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#84
added PasswordRecovery model
parent
d98464d7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
9 deletions
+41
-9
app-data-source.ts
planner-api/src/app-data-source.ts
+2
-1
PasswordRecovery.ts
planner-api/src/models/PasswordRecovery.ts
+35
-0
User.ts
planner-api/src/models/User.ts
+4
-8
No files found.
planner-api/src/app-data-source.ts
View file @
fbf6bc53
...
...
@@ -4,6 +4,7 @@ import {Task} from './models/Task';
import
{
Project
}
from
"./models/Project"
;
import
{
Member
}
from
"./models/Member"
;
import
{
DateTimeTask
}
from
"./models/DateTimeTask"
;
import
{
PasswordRecovery
}
from
"./models/PasswordRecovery"
;
export
const
myDataSource
=
new
DataSource
({
type
:
"postgres"
,
...
...
@@ -12,7 +13,7 @@ export const myDataSource = new DataSource({
username
:
"pluser"
,
password
:
"pluser"
,
database
:
"planner"
,
entities
:
[
User
,
Task
,
Project
,
Member
,
DateTimeTask
],
entities
:
[
User
,
Task
,
Project
,
Member
,
DateTimeTask
,
PasswordRecovery
],
logging
:
true
,
synchronize
:
true
,
// in build switch to false
migrationsRun
:
false
...
...
planner-api/src/models/PasswordRecovery.ts
0 → 100644
View file @
fbf6bc53
import
{
Column
,
Entity
,
PrimaryGeneratedColumn
,
BaseEntity
,
OneToOne
,
CreateDateColumn
,
}
from
'typeorm'
;
import
{
User
}
from
'./User'
;
interface
IPasswordRecovery
{
user
:
User
;
token
:
string
;
enabled
:
boolean
;
createdAt
:
Date
;
}
@
Entity
({
name
:
'PasswordRecovery'
})
export
class
PasswordRecovery
extends
BaseEntity
implements
IPasswordRecovery
{
@
PrimaryGeneratedColumn
(
'uuid'
)
id
!
:
string
;
@
CreateDateColumn
({
name
:
'created_at'
,
type
:
Date
,
default
:
new
Date
()
})
createdAt
!
:
Date
;
@
Column
({
name
:
'token'
,
type
:
'string'
,
nullable
:
false
})
token
!
:
string
;
@
OneToOne
(()
=>
User
,
(
user
:{
passwordRecovery
:
PasswordRecovery
})
=>
user
.
passwordRecovery
)
user
!
:
User
;
@
Column
({
name
:
'enabled'
,
type
:
'boolean'
,
default
:
false
})
enabled
!
:
boolean
;
}
\ No newline at end of file
planner-api/src/models/User.ts
View file @
fbf6bc53
...
...
@@ -5,9 +5,7 @@ import {
CreateDateColumn
,
BeforeInsert
,
BaseEntity
,
ManyToMany
,
OneToMany
,
JoinTable
,
OneToOne
,
}
from
'typeorm'
;
import
{
IsEmail
...
...
@@ -17,6 +15,7 @@ import bcrypt from 'bcrypt';
import
{
nanoid
}
from
'nanoid'
;
import
{
Task
}
from
'./Task'
;
import
{
Member
}
from
'./Member'
;
import
{
PasswordRecovery
}
from
'./PasswordRecovery'
;
const
SALT_WORK_FACTOR
=
10
;
...
...
@@ -35,6 +34,7 @@ interface IUser {
createdAt
:
Date
;
createdTasks
:
Task
[];
members
:
Member
[];
passwordRecovery
:
PasswordRecovery
;
}
...
...
@@ -76,21 +76,17 @@ export class User extends BaseEntity implements IUser {
@
Exclude
({
toPlainOnly
:
true
})
password
!
:
string
;
@
OneToMany
(()
=>
Task
,
(
task
:
{
user
:
User
})
=>
task
.
user
)
createdTasks
!
:
Task
[];
@
OneToMany
(()
=>
Task
,
(
task
:
{
user
:
User
})
=>
task
.
user
)
tasks
!
:
Task
[];
@
OneToMany
(()
=>
Member
,
(
member
:
{
user
:
User
})
=>
member
.
user
)
members
!
:
Member
[];
// @ManyToMany(() => Project,(project: { user: User }) => project.user)
// @JoinTable()
// workerInProjects!: Project[];
@
OneToOne
(()
=>
PasswordRecovery
,
(
passwordRecovery
:{
user
:
User
})
=>
passwordRecovery
.
user
)
passwordRecovery
!
:
PasswordRecovery
;
@
BeforeInsert
()
protected
async
beforeInserthashPassword
():
Promise
<
void
>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment