Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
openmole
gate
Commits
ff85d9dc
Commit
ff85d9dc
authored
Dec 14, 2017
by
Mathieu leclaire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add check route
parent
7d1a0298
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
Servlet.scala
server/src/main/scala/server/Servlet.scala
+18
-2
No files found.
server/src/main/scala/server/Servlet.scala
View file @
ff85d9dc
...
...
@@ -32,8 +32,10 @@ class Servlet(mongoDB: MongoDB) extends ScalatraServlet with AuthenticationSuppo
tags
.
link
(
tags
.
rel
:=
"stylesheet"
,
tags
.
`type`
:=
"text/css"
,
href
:=
"css/bootstrap.min.css"
),
tags
.
script
(
tags
.
`type`
:=
"text/javascript"
,
tags
.
src
:=
"js/gate.js"
)
)
case
class
MongoData
(
collection
:
MongoCollection
,
userSession
:
DBObject
)
def
getMongoData
(
user
:
User
)
=
{
def
getMongoData
(
user
:
User
)
=
{
val
userSession
=
MongoDBObject
(
user
.
login
->
session
.
getId
)
println
(
mongoDB
.
host
+
" => "
+
mongoDB
.
port
)
val
server
=
new
ServerAddress
(
mongoDB
.
host
,
mongoDB
.
port
)
...
...
@@ -42,12 +44,26 @@ class Servlet(mongoDB: MongoDB) extends ScalatraServlet with AuthenticationSuppo
println
(
mongoDB
.
db
+
" ? "
+
mongoDB
.
dataSet
)
MongoData
(
mongoClient
(
mongoDB
.
db
)(
mongoDB
.
dataSet
),
userSession
)
}
val
loginParam
=
"login"
get
(
s
"/check/:$loginParam"
)
{
val
login
=
params
(
loginParam
)
findInMongo
(
User
(
login
)).
isDefined
}
def
findInMongo
(
user
:
User
)
=
{
val
mongoData
=
getMongoData
(
user
)
mongoData
.
collection
.
findOne
(
mongoData
.
userSession
)
}
get
(
"/"
)
{
contentType
=
"text/html"
auth
(
"DB"
)
match
{
case
Some
(
user
)
=>
val
mongoData
=
getMongoData
(
user
)
mongoData
.
collection
.
findOne
(
mongoData
.
userSession
)
match
{
findInMongo
(
user
)
match
{
case
Some
(
x
)
=>
tags
.
html
(
head
,
...
...
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