|
|
@@ -12,6 +12,10 @@ import cn.iselab.mooctest.site.web.logic.UserLogic;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.apache.shiro.authz.UnauthorizedException;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
+import org.apache.shiro.authz.annotation.RequiresUser;
|
|
|
+import org.apache.shiro.session.Session;
|
|
|
+import org.apache.shiro.subject.PrincipalCollection;
|
|
|
+import org.apache.shiro.subject.Subject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
@@ -27,7 +31,7 @@ import java.util.List;
|
|
|
*/
|
|
|
|
|
|
@RestController
|
|
|
-public class ExamController {
|
|
|
+public class ExamController extends BaseController{
|
|
|
|
|
|
@Autowired
|
|
|
ExamLogic examLogic;
|
|
|
@@ -72,9 +76,13 @@ public class ExamController {
|
|
|
return examLogic.getExamList(username);
|
|
|
}
|
|
|
|
|
|
+ @RequiresUser
|
|
|
@RequestMapping(value = "api/exam/{examId}", method = RequestMethod.GET)
|
|
|
public ExamVO getExamById(@PathVariable Long examId) {
|
|
|
- String username = (String) SecurityUtils.getSubject().getPrincipals().getPrimaryPrincipal();
|
|
|
+ Session session=SecurityUtils.getSubject().getSession();
|
|
|
+ Subject subject=SecurityUtils.getSubject();
|
|
|
+ PrincipalCollection principalCollection=subject.getPrincipals();
|
|
|
+ String username = (String) principalCollection.getPrimaryPrincipal();
|
|
|
Long userId = userLogic.findUserByEmail(username).getId();
|
|
|
String permissionStr = String.valueOf(userId) + ":task:view:" + String.valueOf(examId);
|
|
|
if (!SecurityUtils.getSubject().isPermitted(permissionStr)) {
|