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
cb007180
Commit
cb007180
authored
Dec 14, 2017
by
Mathieu leclaire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get Mongo initialization out the / route
parent
9bee3626
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
Servlet.scala
server/src/main/scala/server/Servlet.scala
+9
-9
No files found.
server/src/main/scala/server/Servlet.scala
View file @
cb007180
...
...
@@ -31,19 +31,19 @@ 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"
)
)
val
userSession
=
MongoDBObject
(
user
.
login
->
session
.
getId
)
println
(
mongoDB
.
host
+
" => "
+
mongoDB
.
port
)
val
server
=
new
ServerAddress
(
mongoDB
.
host
,
mongoDB
.
port
)
val
credentials
=
MongoCredential
.
createCredential
(
"accountUser"
,
"products"
,
"password"
.
toCharArray
)
val
mongoClient
=
MongoClient
(
server
,
List
(
credentials
))
println
(
mongoDB
.
db
+
" ? "
+
mongoDB
.
dataSet
)
val
mongoCollection
=
mongoClient
(
mongoDB
.
db
)(
mongoDB
.
dataSet
)
get
(
"/"
)
{
contentType
=
"text/html"
auth
(
"DB"
)
match
{
case
Some
(
user
)
=>
val
userSession
=
MongoDBObject
(
user
.
login
->
session
.
getId
)
println
(
mongoDB
.
host
+
" => "
+
mongoDB
.
port
)
val
server
=
new
ServerAddress
(
mongoDB
.
host
,
mongoDB
.
port
)
val
credentials
=
MongoCredential
.
createCredential
(
"accountUser"
,
"products"
,
"password"
.
toCharArray
)
val
mongoClient
=
MongoClient
(
server
,
List
(
credentials
))
println
(
mongoDB
.
db
+
" ? "
+
mongoDB
.
dataSet
)
val
mongoColl
=
mongoClient
(
mongoDB
.
db
)(
mongoDB
.
dataSet
)
mongoColl
.
findOne
(
userSession
)
match
{
mongoCollection
.
findOne
(
userSession
)
match
{
case
Some
(
x
)
=>
tags
.
html
(
head
,
...
...
@@ -53,7 +53,7 @@ class Servlet(mongoDB: MongoDB) extends ScalatraServlet with AuthenticationSuppo
)
)
case
None
=>
mongoColl
+=
userSession
mongoColl
ection
+=
userSession
tags
.
html
(
head
,
tags
.
body
(
...
...
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