Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
book racker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
THARUNIKA V S
book racker
Commits
50cc2361
Commit
50cc2361
authored
4 years ago
by
V S Tharunika
Browse files
Options
Downloads
Patches
Plain Diff
authentication to input added
parent
c33dbda3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/src/policies/AuthenticationControllerPolicy.js
+48
-0
48 additions, 0 deletions
server/src/policies/AuthenticationControllerPolicy.js
server/src/routes.js
+3
-0
3 additions, 0 deletions
server/src/routes.js
with
51 additions
and
0 deletions
server/src/policies/AuthenticationControllerPolicy.js
0 → 100644
+
48
−
0
View file @
50cc2361
const
Joi
=
require
(
'
joi
'
)
module
.
exports
=
{
register
(
reg
,
res
,
next
){
const
schema
=
{
email
:
Joi
.
string
().
email
(),
password
:
Joi
.
string
().
regex
(
new
regExp
(
'
^[a-zA-Z0-9]{8-32}$
'
)
)
}
const
{
error
,
value
}
=
Joi
.
Validate
(
req
.
body
,
schema
)
if
(
error
){
switch
(
error
.
details
[
0
].
context
.
key
){
case
'
email
'
:
res
.
status
(
400
).
send
({
error
:
'
You must provide a valid email address
'
})
break
case
'
password
'
:
res
.
status
(
400
).
send
({
error
:
'
The password provided failed to match the following rules <br> 1.It must contain only the following characters: lower case, upper case, numerics <br> 2.It must be at least 8 characters in lenght and not greater than 32 characters
'
})
break
default
:
res
.
status
(
400
).
send
({
error
:
'
Invalid registration information
'
})
}
}
else
{
next
()
}
}
}
This diff is collapsed.
Click to expand it.
server/src/routes.js
+
3
−
0
View file @
50cc2361
const
AuthenticationController
=
require
(
'
./controllers/AuthenticationController
'
)
const
AuthenticationControllerPolicy
=
require
(
'
./policies/AuthenticationControllerPolicy
'
)
module
.
exports
=
(
app
)
=>
{
app
.
post
(
'
/register
'
,
AuthenticationControllerPolicy
.
register
,
AuthenticationController
.
register
)
}
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