Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
simcaq-node
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
simcaq
simcaq-node
Commits
b247c029
There was a problem fetching the pipeline summary.
Commit
b247c029
authored
8 years ago
by
Lucas Gabriel Lima
Browse files
Options
Downloads
Patches
Plain Diff
rename signup route to user
parent
72365ac9
No related branches found
No related tags found
1 merge request
!20
Auth
Pipeline
#
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/libs/models/user.js
+3
-2
3 additions, 2 deletions
src/libs/models/user.js
src/libs/routes/api.js
+2
-2
2 additions, 2 deletions
src/libs/routes/api.js
src/libs/routes/user.js
+3
-6
3 additions, 6 deletions
src/libs/routes/user.js
with
8 additions
and
10 deletions
src/libs/models/user.js
+
3
−
2
View file @
b247c029
const
mongoose
=
require
(
'
mongoose
'
);
const
mongoose
=
require
(
'
mongoose
'
);
const
bcrypt
=
require
(
'
bcrypt
'
);
const
bcrypt
=
require
(
'
bcrypt
'
);
const
libs
=
`
${
process
.
cwd
()}
/libs`
;
const
log
=
require
(
`
${
libs
}
/log`
)(
module
);
const
Schema
=
mongoose
.
Schema
;
const
Schema
=
mongoose
.
Schema
;
// set up a mongoose model
// set up a mongoose model
...
@@ -19,7 +20,7 @@ var UserSchema = new Schema({
...
@@ -19,7 +20,7 @@ var UserSchema = new Schema({
UserSchema
.
pre
(
'
save
'
,
function
(
next
)
{
UserSchema
.
pre
(
'
save
'
,
function
(
next
)
{
var
user
=
this
;
var
user
=
this
;
if
(
this
.
isModified
(
'
password
'
)
||
this
.
isNew
)
{
if
(
this
.
isModified
(
'
password
'
)
||
this
.
isNew
)
{
bcrypt
.
genSalt
(
1
28
,
function
(
err
,
salt
)
{
bcrypt
.
genSalt
(
1
0
,
function
(
err
,
salt
)
{
if
(
err
)
{
if
(
err
)
{
return
next
(
err
);
return
next
(
err
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/libs/routes/api.js
+
2
−
2
View file @
b247c029
...
@@ -12,7 +12,7 @@ const city = require('./city');
...
@@ -12,7 +12,7 @@ const city = require('./city');
const
school
=
require
(
'
./school
'
);
const
school
=
require
(
'
./school
'
);
const
signup
=
require
(
'
./
signup
'
);
const
user
=
require
(
'
./
user
'
);
api
.
get
(
'
/
'
,
(
req
,
res
)
=>
{
api
.
get
(
'
/
'
,
(
req
,
res
)
=>
{
res
.
json
({
msg
:
'
SimCAQ API is running
'
});
res
.
json
({
msg
:
'
SimCAQ API is running
'
});
...
@@ -24,6 +24,6 @@ api.use('/api/v1/state', state);
...
@@ -24,6 +24,6 @@ api.use('/api/v1/state', state);
api
.
use
(
'
/api/v1/region
'
,
region
);
api
.
use
(
'
/api/v1/region
'
,
region
);
api
.
use
(
'
/api/v1/city
'
,
city
);
api
.
use
(
'
/api/v1/city
'
,
city
);
api
.
use
(
'
/api/v1/school
'
,
school
);
api
.
use
(
'
/api/v1/school
'
,
school
);
api
.
use
(
'
/api/v1/
signup
'
,
signup
);
api
.
use
(
'
/api/v1/
user
'
,
user
);
module
.
exports
=
api
;
module
.
exports
=
api
;
This diff is collapsed.
Click to expand it.
src/libs/routes/
signup
.js
→
src/libs/routes/
user
.js
+
3
−
6
View file @
b247c029
const
express
=
require
(
'
express
'
);
const
express
=
require
(
'
express
'
);
const
signup
App
=
express
();
const
user
App
=
express
();
const
libs
=
`
${
process
.
cwd
()}
/libs`
;
const
libs
=
`
${
process
.
cwd
()}
/libs`
;
...
@@ -9,10 +9,8 @@ const log = require(`${libs}/log`)(module);
...
@@ -9,10 +9,8 @@ const log = require(`${libs}/log`)(module);
const
User
=
require
(
'
../models/user
'
);
const
User
=
require
(
'
../models/user
'
);
signupApp
.
post
(
'
/
'
,
(
req
,
res
)
=>
{
userApp
.
post
(
'
/
'
,
(
req
,
res
)
=>
{
log
.
debug
(
'
kapo
'
);
if
(
!
req
.
body
.
email
||
!
req
.
body
.
password
)
{
if
(
!
req
.
body
.
email
||
!
req
.
body
.
password
)
{
log
.
info
(
'
kelpo
'
);
res
.
json
({
success
:
false
,
msg
:
'
Please pass email and password.
'
});
res
.
json
({
success
:
false
,
msg
:
'
Please pass email and password.
'
});
}
else
{
}
else
{
var
newUser
=
new
User
({
var
newUser
=
new
User
({
...
@@ -22,7 +20,6 @@ signupApp.post('/', (req, res) => {
...
@@ -22,7 +20,6 @@ signupApp.post('/', (req, res) => {
log
.
debug
(
newUser
.
email
);
log
.
debug
(
newUser
.
email
);
// save the user
// save the user
newUser
.
save
((
err
)
=>
{
newUser
.
save
((
err
)
=>
{
log
.
info
(
'
pepe
'
);
if
(
err
)
{
if
(
err
)
{
return
res
.
json
({
success
:
false
,
msg
:
'
Email already in use.
'
});
return
res
.
json
({
success
:
false
,
msg
:
'
Email already in use.
'
});
}
}
...
@@ -31,4 +28,4 @@ signupApp.post('/', (req, res) => {
...
@@ -31,4 +28,4 @@ signupApp.post('/', (req, res) => {
}
}
});
});
module
.
exports
=
signup
App
;
module
.
exports
=
user
App
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment