Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-CloudComputing
/
D_Team_Khuloud
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
최동원
2020-05-26 19:55:50 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b32ea4a4325b5ef390fd52da8d39a424c39387d3
b32ea4a4
1 parent
0b2240bf
api fix
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
9 deletions
backend/app.js
backend/routes/userlogin/login.js
backend/routes/userlogin/register.js
backend/app.js
View file @
b32ea4a
...
...
@@ -50,10 +50,10 @@ app.use(express.static('views'));
app
.
use
(
passport
.
initialize
());
app
.
use
(
passport
.
session
());
app
.
use
(
'/'
,
indexRouter
);
app
.
use
(
'/user'
,
userRouter
);
app
.
use
(
'/login'
,
loginRouter
);
app
.
use
(
'/RegistUser'
,
registerRouter
);
app
.
use
(
'/
api/
'
,
indexRouter
);
app
.
use
(
'/
api/
user'
,
userRouter
);
app
.
use
(
'/
api/
login'
,
loginRouter
);
app
.
use
(
'/
api/
RegistUser'
,
registerRouter
);
//app.use('/users', usersRouter);
// catch 404 and forward to error handler
...
...
backend/routes/userlogin/login.js
View file @
b32ea4a
...
...
@@ -20,7 +20,7 @@ router.post('/', function(req, res, next) {
if
(
bytes
===
user_pw
)
{
console
.
log
(
"user login successfully"
);
req
.
session
.
user_id
=
result
[
0
].
user_id
;
res
.
redirect
(
'/main'
);
res
.
status
(
200
).
send
({
user_id
:
result
[
0
].
user_id
}
);
}
else
{
console
.
log
(
"wrong password!"
);
}
...
...
backend/routes/userlogin/register.js
View file @
b32ea4a
...
...
@@ -21,7 +21,7 @@ router.post('/', function(req, res, next) {
var
user_phone
=
req
.
body
.
user_phone
;
var
sqlquery
=
"SELECT * FROM users WHERE user_id = ?"
;
connection
.
query
(
sqlquery
,
[
user_id
],
function
(
err
,
r
esult
)
{
connection
.
query
(
sqlquery
,
[
user_id
],
function
(
err
,
r
ows
)
{
if
(
rows
.
length
==
0
)
{
user_pw
=
cryptoM
.
encrypt
(
user_pw
);
console
.
log
(
user_pw
);
...
...
@@ -32,13 +32,12 @@ router.post('/', function(req, res, next) {
console
.
log
(
"inserting user failed"
);
throw
err
;
}
else
{
res
.
redirect
(
'/login
'
);
res
.
status
(
200
).
send
(
'saved
'
);
}
});
}
else
{
res
.
redirect
(
"/login"
);
throw
err
;
res
.
status
(
404
).
send
(
err
);
}
});
});
...
...
Please
register
or
login
to post a comment