use of com.erudika.para.core.Sysprop in project scoold by Erudika.
the class QuestionsController method setSpace.
@GetMapping({ "/questions/space/{space}", "/questions/space" })
public String setSpace(@PathVariable(required = false) String space, HttpServletRequest req, HttpServletResponse res, Model model) {
if ("all".equals(space) || utils.isAllSpaces(space)) {
space = Post.ALL_MY_SPACES + ":" + utils.getLang(req).get("allspaces");
} else {
Sysprop spaceObj = pc.read(utils.getSpaceId(space));
if (!StringUtils.isBlank(space) && spaceObj == null) {
Profile authUser = utils.getAuthUser(req);
if (authUser != null && utils.canAccessSpace(authUser, space)) {
authUser.removeSpace(space);
authUser.update();
}
}
if (spaceObj != null) {
space = spaceObj.getId().concat(Config.SEPARATOR).concat(spaceObj.getName());
} else {
space = Post.DEFAULT_SPACE;
}
}
utils.storeSpaceIdInCookie(space, req, res);
String backTo = HttpUtils.getBackToUrl(req);
if (StringUtils.isBlank(backTo)) {
return get(req.getParameter("sortby"), req, model);
} else {
return "redirect:" + backTo;
}
}
use of com.erudika.para.core.Sysprop in project scoold by Erudika.
the class PrivacyController method edit.
@PostMapping
public String edit(@RequestParam String privacyhtml, HttpServletRequest req, Model model) {
if (!utils.isAuthenticated(req) || !utils.isAdmin(utils.getAuthUser(req))) {
return "redirect:" + PRIVACYLINK;
}
Sysprop privacy = new Sysprop("template" + Config.SEPARATOR + "privacy");
if (StringUtils.isBlank(privacyhtml)) {
utils.getParaClient().delete(privacy);
} else {
privacy.addProperty("html", privacyhtml);
utils.getParaClient().create(privacy);
}
return "redirect:" + PRIVACYLINK;
}
use of com.erudika.para.core.Sysprop in project scoold by Erudika.
the class SigninController method resetPassword.
private boolean resetPassword(String email, String newpass, String token) {
if (StringUtils.isBlank(newpass) || StringUtils.isBlank(token) || !isPasswordStrongEnough(newpass)) {
return false;
}
Sysprop s = pc.read(email);
if (isValidResetToken(s, Config._RESET_TOKEN, token)) {
// avoid removeProperty method because it won't be seen by server
s.addProperty(Config._RESET_TOKEN, "");
s.addProperty("iforgotTimestamp", 0);
s.addProperty(Config._PASSWORD, Utils.bcrypt(newpass));
pc.update(s);
return true;
}
return false;
}
use of com.erudika.para.core.Sysprop in project scoold by Erudika.
the class SigninController method activateWithEmailToken.
private boolean activateWithEmailToken(User u, String token) {
if (u != null && token != null) {
Sysprop s = pc.read(u.getIdentifier());
if (s != null && token.equals(s.getProperty(Config._EMAIL_TOKEN))) {
s.addProperty(Config._EMAIL_TOKEN, "");
pc.update(s);
u.setActive(true);
pc.update(u);
return true;
}
logger.warn("Failed to verify user with email '{}' - invalid verification token.", u.getEmail());
}
return false;
}
use of com.erudika.para.core.Sysprop in project scoold by Erudika.
the class SigninController method verifyEmailIfNecessary.
private void verifyEmailIfNecessary(String name, String email, HttpServletRequest req) {
Sysprop ident = pc.read(email);
if (ident != null && !ident.hasProperty(Config._EMAIL_TOKEN)) {
User u = new User(ident.getCreatorid());
u.setActive(false);
u.setName(name);
u.setEmail(email);
u.setIdentifier(email);
utils.sendWelcomeEmail(u, true, req);
}
}
Aggregations