Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function addroleAction($role) {
- $securityContext = $this->get('security.context');
- $em = $this->getDoctrine()->getManager();
- $user = $this->get('security.context')->getToken()->getUser();
- $userId = $user->getId();
- $userObj = $em->getRepository('ProjectEntityBundle:User')->find($userId);
- switch ($role) {
- case 6://student
- $userObj->addRole('ROLE_STUDENT');
- $em->flush();
- $securityContext->getToken()->setUser($userObj);
- break;
- }
- return $this->redirect($this->generateUrl('check_role'));
- }
- public function checkroleAction() {
- $securityContext = $this->get('security.context');
- if ($securityContext->isGranted('ROLE_STUDENT')) {
- return $this->redirect($this->generateUrl('student_profile'));
- } else {
- return $this->render('ProjectEduBundle:User:selectrole.html.twig');
- }
- }
- $this->get('security.context')->getToken()->setUser($userObject);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement