Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
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
Commits
56c16af3
Commit
56c16af3
authored
Aug 20, 2013
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto format
parent
ff4eccfe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
core/src/main/java/org/b3log/solo/processor/LoginProcessor.java
...rc/main/java/org/b3log/solo/processor/LoginProcessor.java
+14
-13
No files found.
core/src/main/java/org/b3log/solo/processor/LoginProcessor.java
View file @
56c16af3
...
@@ -178,7 +178,7 @@ public class LoginProcessor {
...
@@ -178,7 +178,7 @@ public class LoginProcessor {
*
*
* @param context the specified context
* @param context the specified context
*/
*/
@RequestProcessing
(
value
=
{
"/login"
},
method
=
HTTPRequestMethod
.
POST
)
@RequestProcessing
(
value
=
{
"/login"
},
method
=
HTTPRequestMethod
.
POST
)
public
void
login
(
final
HTTPRequestContext
context
)
{
public
void
login
(
final
HTTPRequestContext
context
)
{
final
HttpServletRequest
request
=
context
.
getRequest
();
final
HttpServletRequest
request
=
context
.
getRequest
();
...
@@ -242,7 +242,7 @@ public class LoginProcessor {
...
@@ -242,7 +242,7 @@ public class LoginProcessor {
* @param context the specified context
* @param context the specified context
* @throws IOException io exception
* @throws IOException io exception
*/
*/
@RequestProcessing
(
value
=
{
"/logout"
},
method
=
HTTPRequestMethod
.
GET
)
@RequestProcessing
(
value
=
{
"/logout"
},
method
=
HTTPRequestMethod
.
GET
)
public
void
logout
(
final
HTTPRequestContext
context
)
throws
IOException
{
public
void
logout
(
final
HTTPRequestContext
context
)
throws
IOException
{
final
HttpServletRequest
httpServletRequest
=
context
.
getRequest
();
final
HttpServletRequest
httpServletRequest
=
context
.
getRequest
();
...
@@ -289,7 +289,7 @@ public class LoginProcessor {
...
@@ -289,7 +289,7 @@ public class LoginProcessor {
*
*
* @param context the specified context
* @param context the specified context
*/
*/
@RequestProcessing
(
value
=
{
"/forgot"
},
method
=
HTTPRequestMethod
.
POST
)
@RequestProcessing
(
value
=
{
"/forgot"
},
method
=
HTTPRequestMethod
.
POST
)
public
void
forgot
(
final
HTTPRequestContext
context
)
{
public
void
forgot
(
final
HTTPRequestContext
context
)
{
final
HttpServletRequest
request
=
context
.
getRequest
();
final
HttpServletRequest
request
=
context
.
getRequest
();
...
@@ -341,7 +341,7 @@ public class LoginProcessor {
...
@@ -341,7 +341,7 @@ public class LoginProcessor {
*
*
* @param context the specified context
* @param context the specified context
*/
*/
@RequestProcessing
(
value
=
{
"/reset"
},
method
=
HTTPRequestMethod
.
POST
)
@RequestProcessing
(
value
=
{
"/reset"
},
method
=
HTTPRequestMethod
.
POST
)
public
void
reset
(
final
HTTPRequestContext
context
)
{
public
void
reset
(
final
HTTPRequestContext
context
)
{
final
HttpServletRequest
request
=
context
.
getRequest
();
final
HttpServletRequest
request
=
context
.
getRequest
();
final
JSONRenderer
renderer
=
new
JSONRenderer
();
final
JSONRenderer
renderer
=
new
JSONRenderer
();
...
@@ -351,9 +351,9 @@ public class LoginProcessor {
...
@@ -351,9 +351,9 @@ public class LoginProcessor {
renderer
.
setJSONObject
(
jsonObject
);
renderer
.
setJSONObject
(
jsonObject
);
try
{
try
{
final
JSONObject
requestJSONObject
;
final
JSONObject
requestJSONObject
;
requestJSONObject
=
Requests
.
parseRequestJSONObject
(
request
,
context
.
getResponse
());
requestJSONObject
=
Requests
.
parseRequestJSONObject
(
request
,
context
.
getResponse
());
final
String
userEmail
=
requestJSONObject
.
getString
(
User
.
USER_EMAIL
);
final
String
userEmail
=
requestJSONObject
.
getString
(
User
.
USER_EMAIL
);
final
String
newPwd
=
requestJSONObject
.
getString
(
"newPwd"
);
final
String
newPwd
=
requestJSONObject
.
getString
(
"newPwd"
);
...
@@ -361,7 +361,7 @@ public class LoginProcessor {
...
@@ -361,7 +361,7 @@ public class LoginProcessor {
user
.
put
(
User
.
USER_PASSWORD
,
newPwd
);
user
.
put
(
User
.
USER_PASSWORD
,
newPwd
);
userMgmtService
.
updateUser
(
user
);
userMgmtService
.
updateUser
(
user
);
LOGGER
.
log
(
Level
.
DEBUG
,
"[{0}]'s password updated successfully."
,
new
Object
[]{
userEmail
});
LOGGER
.
log
(
Level
.
DEBUG
,
"[{0}]'s password updated successfully."
,
new
Object
[]
{
userEmail
});
jsonObject
.
put
(
"succeed"
,
true
);
jsonObject
.
put
(
"succeed"
,
true
);
jsonObject
.
put
(
"to"
,
Latkes
.
getServePath
()
+
"/login?from=reset"
);
jsonObject
.
put
(
"to"
,
Latkes
.
getServePath
()
+
"/login?from=reset"
);
...
@@ -371,7 +371,6 @@ public class LoginProcessor {
...
@@ -371,7 +371,6 @@ public class LoginProcessor {
}
}
}
}
/**
/**
* Whether user is going to update an expired password out of 24 hours.
* Whether user is going to update an expired password out of 24 hours.
*
*
...
@@ -381,7 +380,6 @@ public class LoginProcessor {
...
@@ -381,7 +380,6 @@ public class LoginProcessor {
return
false
;
return
false
;
}
}
/**
/**
* Send the password resetting URL with a random token.
* Send the password resetting URL with a random token.
*
*
...
@@ -399,16 +397,18 @@ public class LoginProcessor {
...
@@ -399,16 +397,18 @@ public class LoginProcessor {
final
String
blogTitle
=
preference
.
getString
(
Preference
.
BLOG_TITLE
);
final
String
blogTitle
=
preference
.
getString
(
Preference
.
BLOG_TITLE
);
final
String
adminEmail
=
preference
.
getString
(
Preference
.
ADMIN_EMAIL
);
final
String
adminEmail
=
preference
.
getString
(
Preference
.
ADMIN_EMAIL
);
final
String
mailSubject
=
langPropsService
.
get
(
"resetPwdMailSubject"
);
final
String
mailSubject
=
langPropsService
.
get
(
"resetPwdMailSubject"
);
final
String
mailBody
=
langPropsService
.
get
(
"resetPwdMailBody"
)
+
" "
+
Latkes
.
getServePath
()
+
"/forgot?token="
+
token
+
"&login="
+
userEmail
;
final
String
mailBody
=
langPropsService
.
get
(
"resetPwdMailBody"
)
+
" "
+
Latkes
.
getServePath
()
+
"/forgot?token="
+
token
+
"&login="
+
userEmail
;
final
MailService
.
Message
message
=
new
MailService
.
Message
();
final
MailService
.
Message
message
=
new
MailService
.
Message
();
final
JSONObject
option
=
new
JSONObject
();
final
JSONObject
option
=
new
JSONObject
();
option
.
put
(
Keys
.
OBJECT_ID
,
token
);
option
.
put
(
Keys
.
OBJECT_ID
,
token
);
option
.
put
(
Option
.
OPTION_CATEGORY
,
"passwordReset"
);
option
.
put
(
Option
.
OPTION_CATEGORY
,
"passwordReset"
);
option
.
put
(
Option
.
OPTION_VALUE
,
System
.
currentTimeMillis
());
option
.
put
(
Option
.
OPTION_VALUE
,
System
.
currentTimeMillis
());
final
Transaction
transaction
=
optionRepository
.
beginTransaction
();
final
Transaction
transaction
=
optionRepository
.
beginTransaction
();
optionRepository
.
add
(
option
);
optionRepository
.
add
(
option
);
transaction
.
commit
();
transaction
.
commit
();
...
@@ -423,7 +423,7 @@ public class LoginProcessor {
...
@@ -423,7 +423,7 @@ public class LoginProcessor {
jsonObject
.
put
(
"to"
,
Latkes
.
getServePath
()
+
"/login?from=forgot"
);
jsonObject
.
put
(
"to"
,
Latkes
.
getServePath
()
+
"/login?from=forgot"
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"resetPwdSuccessSend"
));
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"resetPwdSuccessSend"
));
LOGGER
.
log
(
Level
.
DEBUG
,
"Sending a mail[mailSubject={0}, mailBody=[{1}] to [{2}]"
,
new
Object
[]{
mailSubject
,
mailBody
,
userEmail
});
LOGGER
.
log
(
Level
.
DEBUG
,
"Sending a mail[mailSubject={0}, mailBody=[{1}] to [{2}]"
,
new
Object
[]
{
mailSubject
,
mailBody
,
userEmail
});
}
}
/**
/**
...
@@ -454,19 +454,20 @@ public class LoginProcessor {
...
@@ -454,19 +454,20 @@ public class LoginProcessor {
dataModel
.
put
(
Common
.
STATIC_RESOURCE_VERSION
,
Latkes
.
getStaticResourceVersion
());
dataModel
.
put
(
Common
.
STATIC_RESOURCE_VERSION
,
Latkes
.
getStaticResourceVersion
());
dataModel
.
put
(
Preference
.
BLOG_TITLE
,
preference
.
getString
(
Preference
.
BLOG_TITLE
));
dataModel
.
put
(
Preference
.
BLOG_TITLE
,
preference
.
getString
(
Preference
.
BLOG_TITLE
));
final
String
token
=
request
.
getParameter
(
"token"
);
final
String
token
=
request
.
getParameter
(
"token"
);
final
String
email
=
request
.
getParameter
(
"login"
);
final
String
email
=
request
.
getParameter
(
"login"
);
final
JSONObject
tokenObj
=
optionQueryService
.
getOptionById
(
token
);
final
JSONObject
tokenObj
=
optionQueryService
.
getOptionById
(
token
);
if
(
tokenObj
==
null
)
{
if
(
tokenObj
==
null
)
{
dataModel
.
put
(
"inputType"
,
"email"
);
dataModel
.
put
(
"inputType"
,
"email"
);
}
else
{
}
else
{
//TODO verify the expired time in the tokenObj
//
TODO verify the expired time in the tokenObj
dataModel
.
put
(
"inputType"
,
"password"
);
dataModel
.
put
(
"inputType"
,
"password"
);
dataModel
.
put
(
"userEmailHidden"
,
email
);
dataModel
.
put
(
"userEmailHidden"
,
email
);
}
}
final
String
from
=
request
.
getParameter
(
"from"
);
final
String
from
=
request
.
getParameter
(
"from"
);
if
(
"forgot"
.
equals
(
from
))
{
if
(
"forgot"
.
equals
(
from
))
{
dataModel
.
put
(
"resetMsg"
,
langPropsService
.
get
(
"resetPwdSuccessSend"
));
dataModel
.
put
(
"resetMsg"
,
langPropsService
.
get
(
"resetPwdSuccessSend"
));
}
else
if
(
"reset"
.
equals
(
from
))
{
}
else
if
(
"reset"
.
equals
(
from
))
{
...
...
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