Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
Triz_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
sdy
2020-04-26 15:07:22 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2b33510e4c1f79e7baeeac7363eeb462fef20d19
2b33510e
1 parent
27e56cf8
update user's phone number value
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
back/src/api/User/createAccount/createAccount.js
back/src/utils.js
back/src/api/User/createAccount/createAccount.js
View file @
2b33510
import
{
prisma
,
generateToken
}
from
"../../../utils"
;
import
{
prisma
,
generateToken
,
changePhoneNumber
}
from
"../../../utils"
;
import
bcrypt
from
"bcryptjs"
;
export
default
{
...
...
@@ -6,6 +6,8 @@ export default {
createAccount
:
async
(
_
,
args
)
=>
{
const
{
name
,
password
,
email
,
bio
,
avatarUrl
,
phoneNum
}
=
args
;
const
encryptPw
=
await
bcrypt
.
hash
(
password
,
10
);
// TODO: Find user's country code and change new phone number value
const
newPhoneNumber
=
await
changePhoneNumber
(
phoneNum
,
"+82"
);
const
user
=
await
prisma
.
user
.
create
({
data
:
{
name
,
...
...
@@ -13,7 +15,7 @@ export default {
bio
,
avatarUrl
,
password
:
encryptPw
,
phoneNum
,
phoneNum
:
newPhoneNumber
,
},
});
const
token
=
generateToken
(
user
.
id
);
...
...
back/src/utils.js
View file @
2b33510
...
...
@@ -23,6 +23,13 @@ export const isAuthenticated = (request) => {
return
;
};
export
const
changePhoneNumber
=
(
phoneNum
,
locationNum
)
=>
{
var
leftStr
=
locationNum
;
var
rightStr
=
phoneNum
.
slice
(
1
,
phoneNum
.
length
());
var
newStr
=
leftStr
+
rightStr
;
return
newStr
;
};
export
const
generateSecret
=
()
=>
{
const
randomNumber
=
Math
.
floor
(
Math
.
random
()
*
adjectives
.
length
);
return
`
${
adjectives
[
randomNumber
]}
${
nouns
[
randomNumber
]}
`
;
...
...
Please
register
or
login
to post a comment