Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
solo-1
Commits
bc6d769f
Unverified
Commit
bc6d769f
authored
Nov 04, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
#12932 Cookie
parent
2ade309f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
0 deletions
+13
-0
src/main/java/org/b3log/solo/processor/IndexProcessor.java
src/main/java/org/b3log/solo/processor/IndexProcessor.java
+1
-0
src/main/java/org/b3log/solo/processor/console/SkinConsole.java
...in/java/org/b3log/solo/processor/console/SkinConsole.java
+2
-0
src/main/java/org/b3log/solo/service/StatisticMgmtService.java
...ain/java/org/b3log/solo/service/StatisticMgmtService.java
+3
-0
src/main/java/org/b3log/solo/util/Solos.java
src/main/java/org/b3log/solo/util/Solos.java
+7
-0
No files found.
src/main/java/org/b3log/solo/processor/IndexProcessor.java
View file @
bc6d769f
...
@@ -127,6 +127,7 @@ public class IndexProcessor {
...
@@ -127,6 +127,7 @@ public class IndexProcessor {
cookie
=
new
Cookie
(
Common
.
COOKIE_NAME_MOBILE_SKIN
,
specifiedSkin
);
cookie
=
new
Cookie
(
Common
.
COOKIE_NAME_MOBILE_SKIN
,
specifiedSkin
);
}
}
cookie
.
setMaxAge
(
60
*
60
);
// 1 hour
cookie
.
setMaxAge
(
60
*
60
);
// 1 hour
cookie
.
setPath
(
"/"
);
response
.
addCookie
(
cookie
);
response
.
addCookie
(
cookie
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_LOCALE_STRING
),
(
String
)
context
.
attr
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_LOCALE_STRING
),
(
String
)
context
.
attr
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
...
...
src/main/java/org/b3log/solo/processor/console/SkinConsole.java
View file @
bc6d769f
...
@@ -166,9 +166,11 @@ public class SkinConsole {
...
@@ -166,9 +166,11 @@ public class SkinConsole {
final
Response
response
=
context
.
getResponse
();
final
Response
response
=
context
.
getResponse
();
final
Cookie
skinDirNameCookie
=
new
Cookie
(
Common
.
COOKIE_NAME_SKIN
,
skin
.
getString
(
Option
.
ID_C_SKIN_DIR_NAME
));
final
Cookie
skinDirNameCookie
=
new
Cookie
(
Common
.
COOKIE_NAME_SKIN
,
skin
.
getString
(
Option
.
ID_C_SKIN_DIR_NAME
));
skinDirNameCookie
.
setMaxAge
(
60
*
60
);
// 1 hour
skinDirNameCookie
.
setMaxAge
(
60
*
60
);
// 1 hour
skinDirNameCookie
.
setPath
(
"/"
);
response
.
addCookie
(
skinDirNameCookie
);
response
.
addCookie
(
skinDirNameCookie
);
final
Cookie
mobileSkinDirNameCookie
=
new
Cookie
(
Common
.
COOKIE_NAME_MOBILE_SKIN
,
skin
.
getString
(
Option
.
ID_C_MOBILE_SKIN_DIR_NAME
));
final
Cookie
mobileSkinDirNameCookie
=
new
Cookie
(
Common
.
COOKIE_NAME_MOBILE_SKIN
,
skin
.
getString
(
Option
.
ID_C_MOBILE_SKIN_DIR_NAME
));
mobileSkinDirNameCookie
.
setMaxAge
(
60
*
60
);
// 1 hour
mobileSkinDirNameCookie
.
setMaxAge
(
60
*
60
);
// 1 hour
mobileSkinDirNameCookie
.
setPath
(
"/"
);
response
.
addCookie
(
mobileSkinDirNameCookie
);
response
.
addCookie
(
mobileSkinDirNameCookie
);
ret
.
put
(
Keys
.
STATUS_CODE
,
true
);
ret
.
put
(
Keys
.
STATUS_CODE
,
true
);
...
...
src/main/java/org/b3log/solo/service/StatisticMgmtService.java
View file @
bc6d769f
...
@@ -178,12 +178,14 @@ public class StatisticMgmtService {
...
@@ -178,12 +178,14 @@ public class StatisticMgmtService {
final
StringBuilder
builder
=
new
StringBuilder
(
"["
).
append
(
"\""
).
append
(
request
.
getRequestURI
()).
append
(
"\"]"
);
final
StringBuilder
builder
=
new
StringBuilder
(
"["
).
append
(
"\""
).
append
(
request
.
getRequestURI
()).
append
(
"\"]"
);
final
Cookie
c
=
new
Cookie
(
"visited"
,
URLs
.
encode
(
builder
.
toString
()));
final
Cookie
c
=
new
Cookie
(
"visited"
,
URLs
.
encode
(
builder
.
toString
()));
c
.
setMaxAge
(
COOKIE_EXPIRY
);
c
.
setMaxAge
(
COOKIE_EXPIRY
);
c
.
setPath
(
"/"
);
response
.
addCookie
(
c
);
response
.
addCookie
(
c
);
}
else
if
(
needToAppend
)
{
}
else
if
(
needToAppend
)
{
cookieJSONArray
.
put
(
request
.
getRequestURI
());
cookieJSONArray
.
put
(
request
.
getRequestURI
());
final
Cookie
c
=
new
Cookie
(
"visited"
,
URLs
.
encode
(
cookieJSONArray
.
toString
()));
final
Cookie
c
=
new
Cookie
(
"visited"
,
URLs
.
encode
(
cookieJSONArray
.
toString
()));
c
.
setMaxAge
(
COOKIE_EXPIRY
);
c
.
setMaxAge
(
COOKIE_EXPIRY
);
c
.
setPath
(
"/"
);
response
.
addCookie
(
c
);
response
.
addCookie
(
c
);
}
}
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
...
@@ -191,6 +193,7 @@ public class StatisticMgmtService {
...
@@ -191,6 +193,7 @@ public class StatisticMgmtService {
final
Cookie
c
=
new
Cookie
(
"visited"
,
""
);
final
Cookie
c
=
new
Cookie
(
"visited"
,
""
);
c
.
setMaxAge
(
0
);
c
.
setMaxAge
(
0
);
c
.
setPath
(
"/"
);
response
.
addCookie
(
c
);
response
.
addCookie
(
c
);
}
}
...
...
src/main/java/org/b3log/solo/util/Solos.java
View file @
bc6d769f
...
@@ -266,6 +266,7 @@ public final class Solos {
...
@@ -266,6 +266,7 @@ public final class Solos {
final
String
tokenVal
=
cookieJSONObject
.
optString
(
Keys
.
TOKEN
);
final
String
tokenVal
=
cookieJSONObject
.
optString
(
Keys
.
TOKEN
);
final
String
token
=
StringUtils
.
substringBeforeLast
(
tokenVal
,
":"
);
final
String
token
=
StringUtils
.
substringBeforeLast
(
tokenVal
,
":"
);
if
(
StringUtils
.
equals
(
b3Key
,
token
))
{
if
(
StringUtils
.
equals
(
b3Key
,
token
))
{
login
(
user
,
response
);
return
user
;
return
user
;
}
}
}
}
...
@@ -273,6 +274,8 @@ public final class Solos {
...
@@ -273,6 +274,8 @@ public final class Solos {
LOGGER
.
log
(
Level
.
TRACE
,
"Parses cookie failed, clears the cookie [name="
+
COOKIE_NAME
+
"]"
);
LOGGER
.
log
(
Level
.
TRACE
,
"Parses cookie failed, clears the cookie [name="
+
COOKIE_NAME
+
"]"
);
final
Cookie
cookie
=
new
Cookie
(
COOKIE_NAME
,
""
);
final
Cookie
cookie
=
new
Cookie
(
COOKIE_NAME
,
""
);
cookie
.
setMaxAge
(
0
);
cookie
.
setMaxAge
(
0
);
cookie
.
setPath
(
"/"
);
cookie
.
setHttpOnly
(
true
);
response
.
addCookie
(
cookie
);
response
.
addCookie
(
cookie
);
}
}
...
@@ -296,6 +299,8 @@ public final class Solos {
...
@@ -296,6 +299,8 @@ public final class Solos {
final
String
cookieValue
=
Crypts
.
encryptByAES
(
cookieJSONObject
.
toString
(),
COOKIE_SECRET
);
final
String
cookieValue
=
Crypts
.
encryptByAES
(
cookieJSONObject
.
toString
(),
COOKIE_SECRET
);
final
Cookie
cookie
=
new
Cookie
(
COOKIE_NAME
,
cookieValue
);
final
Cookie
cookie
=
new
Cookie
(
COOKIE_NAME
,
cookieValue
);
cookie
.
setMaxAge
(
COOKIE_EXPIRY
);
cookie
.
setMaxAge
(
COOKIE_EXPIRY
);
cookie
.
setPath
(
"/"
);
cookie
.
setHttpOnly
(
true
);
response
.
addCookie
(
cookie
);
response
.
addCookie
(
cookie
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
WARN
,
"Can not write cookie"
,
e
);
LOGGER
.
log
(
Level
.
WARN
,
"Can not write cookie"
,
e
);
...
@@ -313,6 +318,8 @@ public final class Solos {
...
@@ -313,6 +318,8 @@ public final class Solos {
if
(
null
!=
response
)
{
if
(
null
!=
response
)
{
final
Cookie
cookie
=
new
Cookie
(
COOKIE_NAME
,
""
);
final
Cookie
cookie
=
new
Cookie
(
COOKIE_NAME
,
""
);
cookie
.
setMaxAge
(
0
);
cookie
.
setMaxAge
(
0
);
cookie
.
setPath
(
"/"
);
cookie
.
setHttpOnly
(
true
);
response
.
addCookie
(
cookie
);
response
.
addCookie
(
cookie
);
}
}
}
}
...
...
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