Process accept user invitation form.

@param CreateUserWithTokenRequest $request
@return \Illuminate\Http\JsonResponse
430832
public function postAccept(CreateUserWithTokenRequest $request)
    {
        if (! $request->has('token')) abort(403);
        if (! $invitation = $this->validateToken($request->input('token'))) abort(403);

        $user = User::create([
            'name' => $request->input('name'),
            'email' => $request->input('email'),
            'password' => bcrypt($request->input('password')),
        ]);

        event(new UserCreated($user));

        $invitation = UserInvitation::where('token', $request->input('token'))->first();
        $invitation->user()->associate($user);
        $invitation->accept();

        return Response::json(['created' => true ]);
    }
157402
public function createAccountAction(Request $request)
    {
        $selfRegistration = $this->platformConfigHandler->getParameter('allow_self_registration');
        $casLogin = $request->getSession()->get('CAS_AUTHENTICATION_USER_ID');
        if (empty($casLogin) || !$selfRegistration) {
            return $this->redirectToRoute('claro_index');
        }

        return $this->casManager->createNewAccount($request, $casLogin);
    }
100215
public function postProfile(Request $request)
    {
        $user = $this->getAuthenticatedUser();

        if ($this->service->update($user->id, $request->all())) {
            return response()->json(compact('user'));
        }

        return response()->json(['error' => 'Could not update user']);
    }
154005
public function postAction(Request $request)
    {
        $params = array();
        $content = $request->getContent();
        if (!empty($content))
        {
            $params = json_decode($content, true); // 2nd param to get as array
        }
        $uuid = $params['authData']['anonymous']['id'];
        $pw   = $params['authData']['anonymous']['pw'];
        /* @var $user UserInterface */
        $user = $this->registerAnonymous($uuid, $pw);

        return new JsonResponse([
            'createDate'=> $user->getCreatedAt()
            , 'objectId'=> $user->getId()
            , 'userName'=> $user->getUsername()
            , 'authData'=> $params['authData']
            , 'updateDate'=> $user->getUpdatedAt()
        ]);
    }
979264
public function post(Request $request)
    {
        // Validate user
        $email = Arr::get($this->getContentAsArray($request), 'email');
        $user  = $this->userService->findByEmail($email);

        if (! $user) {
            return $this->createNotFoundResponse();
        }

        // If a token exists that won't expire in the next 5 minutes, send it
        $token = $this->userService->findTokenBy([
            'user_id'       => $user->getId(),
            'token_type_id' => TokenEntity::TYPE_RESET_PASSWORD,
            ['expires', '>', time() + 5*60],
        ]);

        // Otherwise create a new token
        if (! $token) {
            $token = $this->userService->createUserToken([
                'user_id'       => $user->getId(),
                'token_type_id' => TokenEntity::TYPE_RESET_PASSWORD,
                'expires'       => strtotime('+1 day', time()),
            ]);
        }

        $this->resetPasswordView->setUserToken($token);

        $email = $this->emailService->createFromArray([
            'recipient_email' => $user->getEmail(),
            'subject'         => 'Reset Your Password',
            'message'         => (string) $this->resetPasswordView,
        ]);

        $this->emailService->enqueueSendEmailJob($email);

        return $this->create204Response(204, '');
    }
152544
public function store(CreateUserRequest $request)
    {
        $user = User::create([
            'name' => $request->input('name'),
            'email' => $request->input('email'),
            'password' => bcrypt($request->input('password')),
        ]);

        event(new UserCreated($user));

        return $user;
    }
726318
public static function create_from_request($request) {
        if($type = $request->getVar('accept')) {
            try {
                if(array_key_exists($type, self::$lookup)) {
                    return self::create(self::$lookup[$type]);
                }
            } catch(\Exception $e) {}
        }
        $types = $request->getAcceptMimetypes();
        foreach($types as $type) {
            try {
                return self::create($type);
            } catch(RestUserException $e) {}
        }
        return self::create();
    }
889982
public function store(SendInvitationRequest $request)
    {
        $invitation = UserInvitation::where(['email' => $request->input('email')])->first();
        if (!$invitation) {
            $invitation = UserInvitation::create($request->only(['email','state','token']));
        }

        // NOTE : this method trigger method "created" in UserInvitationObserver. Fire also and event to enable hooking.
        event(new UserInvited($invitation));

        return Response::json(['created' => true ]);
    }
1194777
private function createToken(Request $request)
    {
        $tokenString = $request->headers->get($this->header);

        if ($this->header == self::HEADER_AUTH && 0 === strpos((string)$tokenString, 'Bearer ')) {
            $tokenString = substr($tokenString, 7);
        }

        if (!$tokenString) {
            return null;
        }

        return new JwtAuthenticationToken([], $tokenString);
    }
52251
public function getActivate(Request $request, $token)
    {

        $user = User::where('token', $token)->first();
        if (!$user) {
            throw new NotFoundHttpException;
        }

        $user->is_activated = true;
        $user->token        = null;
        $user->save();

        if (method_exists($this, 'userActivated')) {
            $this->userRegistered($request, $token, $user);
        }

        return view($this->getUserActivatingView(), ['user' => $user, 'token' => $token]);
    }
1371930
public function submitAction(Request $request)
    {
        try {
            $manager = $this->get('ongr_settings.settings_manager');
            $data = $request->get('setting');

            if (!empty($data['value']) && !is_string($data['value'])) {
                $data['value'] = json_encode($data['value']);
            }

            if ($request->get('force')) {
                $name = $request->get('name');
                $manager->update($name, $data);
            } else {
                $manager->create($data);
            }

            return new JsonResponse(['error' => false]);
        } catch (\Exception $e) {
            return new JsonResponse(
                [
                    'error' => true,
                    'message' => 'Error occurred! Something is wrong with provided data. '.
                        'Please try to submit form again.'
                ]
            );
        }
    }
837142
public function createAction(Request $request)
    {
        $user = new User();
        $form = $this->createCreateForm($user);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            
            $user->setPassword($this->get('security.password_encoder')
                    ->encodePassword($user, $form['plainPassword']['password']->getData()));
            
            $em->persist($user);
            $em->flush();

            return $this->redirect($this->generateUrl('admin_user_show', array('id' => $user->getId())));
        }

        return $this->render('ChillMainBundle:User:new.html.twig', array(
            'entity' => $user,
            'form'   => $form->createView(),
        ));
    }
52627
public function add(Request $request){
    	$userId = Auth::user()->id;
    	$parent = $request->parent;
    	$commentBody = $request->comment;
    	$itemId = $request->item_id;

        $user = self::getUser($userId);
        $userPic = $user['avatar'];
        if($userPic == 'gravatar'){
            $hash = md5(strtolower(trim($user['email'])));
            $userPic = "http://www.gravatar.com/avatar/$hash?d=identicon";
        }

	    $comment = new Comment;
	    $comment->user_id = $userId;
	    $comment->parent_id = $parent;
	    $comment->item_id = $itemId;
	    $comment->comment = $commentBody;

	    $comment->save();

	    $id = $comment->id;
    	return response()->json(['flag' => 1, 'id' => $id, 'comment' => $commentBody, 'item_id' => $itemId, 'userName' => $user['name'], 'userPic' => $userPic]);
// dd($comment);
    }
280304
public function postRegister(RegisterRequest $request)
    {
        $inputs = $request->except('_token');
        $inputs['password'] = Hash::make($inputs['password']);
        $user = $this->userRepo->create($inputs);

        Event::fire(new UserHasCreated($user));

        return Redirect::to('/');
    }
926838
public function addAction(Request $request): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('state', 'administrate'));
        $defaultLanguageCode = reset($this->languages);

        $form = $this->formFactory->createObjectStateGroup(
            new ObjectStateGroupCreateData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form,
                function (ObjectStateGroupCreateData $data) use ($defaultLanguageCode) {
                    $createStruct = $this->objectStateService->newObjectStateGroupCreateStruct(
                        $data->getIdentifier()
                    );
                    $createStruct->defaultLanguageCode = $defaultLanguageCode;
                    $createStruct->names = [$defaultLanguageCode => $data->getName()];
                    $group = $this->objectStateService->createObjectStateGroup($createStruct);

                    $this->notificationHandler->success(
                        $this->translator->trans(
                            /** @Desc("Object state group '%name%' created.") */
                            'object_state_group.create.success',
                            ['%name%' => $data->getName()],
                            'object_state'
                        )
                    );

                    return $this->redirectToRoute('ezplatform.object_state.group.view', [
                        'objectStateGroupId' => $group->id,
                    ]);
                });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->render('@ezdesign/admin/object_state_group/add.html.twig', [
            'form' => $form->createView(),
        ]);
    }
1224193
public function postRequest(Request $request)
    {
        // Validate the form data
        $result = $this->validate($request, [
            'email' => 'required|email|max:255'
        ]);

        // Fetch the user in question
        $user = Sentinel::findUserByCredentials(['email' => $request->get('email')]);

        // Only send them an email if they have a valid, inactive account
        if ($user) {
            // Generate a new code
            $reminder = Reminder::create($user);

            // Send the email
            $code = $reminder->code;
            $email = $user->email;
            Mail::to($email)->queue(new CentaurPasswordReset($code));
        }

        $message = 'Instructions for changing your password will be sent to your email address if it is associated with a valid account.';

        if ($request->expectsJson()) {
            return response()->json(['message' => $message, 'code' => $code], 200);
        }

        Session::flash('success', $message);
        return redirect()->route('dashboard');
    }
164004
public function onAuthenticationSuccess( Request $request, TokenInterface $token )
	{
		// if AJAX login
		if ( ! $request->isXmlHttpRequest() ) {
			throw new NotFoundHttpException('Must use AJAX Login');
		}

		return new JsonResponse(array(
			"success" => true
		));
	}