Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ApplicationGommette
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
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
Boris OUYA
ApplicationGommette
Commits
5cdc894a
Commit
5cdc894a
authored
2 years ago
by
Boris
Browse files
Options
Downloads
Patches
Plain Diff
Plus d'authentified ni de connected
parent
00cbec84
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/com/uca/StartServer.java
+11
-8
11 additions, 8 deletions
src/com/uca/StartServer.java
src/com/uca/core/ProfCore.java
+2
-0
2 additions, 0 deletions
src/com/uca/core/ProfCore.java
src/main/resources/views/login.ftl
+1
-0
1 addition, 0 deletions
src/main/resources/views/login.ftl
with
14 additions
and
8 deletions
src/com/uca/StartServer.java
+
11
−
8
View file @
5cdc894a
...
...
@@ -8,6 +8,7 @@ import java.sql.Date;
import
java.util.*
;
import
static
spark
.
Spark
.*;
import
java.text.*
;
import
java.io.IOException
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
...
...
@@ -21,8 +22,6 @@ public class StartServer {
//.\gradlew run
public
static
boolean
authentified
=
false
;
public
static
ProfEntity
connected
=
null
;
public
static
String
SEL
=
"MangeMesCookies"
;
...
...
@@ -52,10 +51,7 @@ public class StartServer {
_Initializer
.
Init
();
// Debug:
connected
=
_Initializer
.
DEBUG_BORIS_ADMIN
;
authentified
=
true
;
//Defining our routes
//displayLocalHost(portNb, "users");
get
(
"/users"
,
(
req
,
res
)
->
{
...
...
@@ -100,6 +96,9 @@ public class StartServer {
get
(
"/welcome"
,(
req
,
res
)
->
{
if
(
verificationSession
(
req
))
{
int
id
=
Integer
.
parseInt
(
req
.
session
().
attribute
(
"user-id"
).
toString
());
ProfEntity
connected
=
Core
.
Prof
.
getById
(
id
);
return
ProfGUI
.
getWelcomePage
(
connected
);
}
else
...
...
@@ -136,9 +135,8 @@ public class StartServer {
if
(
found
!=
null
)
{
connected
=
found
;
spark
.
Session
s
=
req
.
session
(
true
);
s
.
attribute
(
"user
"
,
found
.
getUserName
(
));
s
.
attribute
(
"user
-id"
,
Integer
.
toString
(
found
.
getId
()
));
String
id
=
s
.
id
();
res
.
cookie
(
"session-id"
,
id
);
res
.
redirect
(
"/welcome"
);
...
...
@@ -203,10 +201,15 @@ public class StartServer {
return
null
;
}
String
raison
=
req
.
queryParams
(
"raison"
);
int
idGommette
=
Integer
.
parseInt
(
req
.
queryParams
(
"idGommette"
));
int
idEleve
=
Integer
.
parseInt
(
req
.
queryParams
(
"idEleve"
));
int
id
=
Integer
.
parseInt
(
req
.
session
().
attribute
(
"user-id"
).
toString
());
ProfEntity
connected
=
Core
.
Prof
.
getById
(
id
);
Core
.
GommetteAttrib
.
create
(
idEleve
,
connected
.
getId
(),
idGommette
,
new
java
.
sql
.
Date
(
System
.
currentTimeMillis
()),
raison
);
res
.
redirect
(
"/eleves/"
+
req
.
queryParams
(
"idEleve"
));
return
null
;
...
...
This diff is collapsed.
Click to expand it.
src/com/uca/core/ProfCore.java
+
2
−
0
View file @
5cdc894a
...
...
@@ -25,6 +25,8 @@ public class ProfCore extends _DefaultCore<ProfEntity> {
return
dao
.
create
(
entity
);
}
public
ProfEntity
getByLoginPair
(
String
username
,
String
password
)
throws
Exception
{
String
hash_pwd
=
Hash
.
hashSHA256
(
StartServer
.
SEL
+
password
);
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/views/login.ftl
+
1
−
0
View file @
5cdc894a
...
...
@@ -8,6 +8,7 @@
<input name="userName" required>
<label for="password">Mot de passe</label>
<input name="password" type="password" required>
<button type="submit" placeholder="Supprimer...">Envoyer</button>
</
form
>
...
...
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