Elgg - perform an action for a guest user - php

I need to perform an action like save the result for a survey for a guest user(non registered/not logged in) in elgg, in which the user only gets a page having a form of data .
I manage to get this thing but, when i submit the action it shows the error
Sorry, you cannot perform this action while logged out.
and redirect to the login page.
How to solve this issue
Thanks

check the register_action , there is a parameter $public with options true/false
if u set it to true this action be accessed by people not logged into the system.

The problem is that each action that is called gets checked by elgg with the action-_gatekeeper() method.
The easiest way to get around this is to not have your survey results sent to a script defined as an action, but rather just have your form submit directly to your script (have the submit URL be something like www.your site.com/mod/yourPlugin/handleSurvey.php )

Yes that's true, you can set action public, but after that for saving results in elgg, you have to override the accesses so that not loggedin user can save data to database.
Check for the Permissions Check

Related

return to page on which login button was pressed - Laravel 5.2

I am trying to implement a UX guideline: let an user return to location where he clicked /login button.
My idea is to use
$request->session()->put('get_back_to_here', URL::back());
or put an extra field in the login form /login, with value URL::back().
My problem
where is the logic responsible for processing form - it is not in the Auth/AuthController.php.
Is there any other way to do this?
I have the same task with social logins. Should I use a cookie?
I followed this tutorial to implement SUCCESSFULLY the social login functions:
http://goodheads.io/2015/08/24/using-facebook-authentication-for-login-in-laravel-5/
Modyfying the
return redirect()->route('home');
so that it would read a cookie would be simple. But would that be a best practice?
The logic should really go to the AppController or at an event listener. I assume It's generic functionality that will be used in many controllers.
From what I understand, you will have a login button in many pages like a header or a footer so you wish to store the place where he clicked at . look at laravel redirects and routing https://laravel.com/docs/5.1/responses#redirecting-controller-actions
https://laravel.com/docs/5.2/routing#accessing-the-current-route
You can use the Route::current() when the login button is pressed to get the current route and store it in the Session. there is nothing wrong with using the session for something like this.
Alternatively, you can bind an event to listen to the login action (look at https://laravel.com/docs/5.2/events#defining-events) and dynamically create a button that appears after login and sticks to the header or footer of your page that upon click will redirect to the Route::current() url that was stored upon login action.
Hope it helps to give you an idea

PHP Automatically login and fill a form with data from URL

I have two software. I want to create a link in the first one to call and fill a form in the second one.
The second one is written in PHP (with CakePHP) and can be accessed by authenticate users. I need to automatically log the users in and fill the form on click of the link.
I don't know how to do that?
I was thinking of this solution, but can you please tell me if you see a better one.
-The link will contain all information to login my user and all information to prefill the form
-The link will be dedicated to this action in my php application. It will automatically log my user in, put the form data in session and redirect to the form page.
-In the form page, if the session variable is not empty I will fill my form.
Please help me and tell me what do you think of this plan.
You can make a route that log you automatically just pass in args your login/pw encoded in md5 after you redirect to what you want.
I am not using the cake but maybe you need to adjust what I propose to fill your wish
You need to turn the GET parameters into POST, that's all and it's dead easy.
See https://en.wikipedia.org/wiki/Post/Redirect/Get

Display login success without adding to every page

So I want to add like a box that says that you have been logged in successfully, but I don't want to add the code to every page. How can I make it so that the code is added to the login page (which redirects you to the home page, or whatever)?
Use the $_POST global on the page what is the submit page of the login form. The most useful is when that is the index.php, which includes all the other active pages.
if( isset($_POST['loginname']) )
{
>>write out the welcome message<<
}
it means, that immediatelly before that was submitted the form with the loginname input field.
After that save the login event into a session (ex. $_SESSION=$_POST['loginname']), only this will accesible on all further pages. But on logout do not forget to clear that session.
That depends on your login system structure but if you have a login box at the top of everypage for example there should be a script to process those logins without adding code to everypage other than a header include.
Again, depends on how your site is setup
If your question is how to send that information and store it from page to page, you would use _POST to send to login page, store the information in a session/cookie. Etc
Edit: if i am misunderstanding the question, let me know.
The question is not really clear. Looks like you need to think of a include file which can have your success message and related processing.

design login controller logic using Yii

I am thinking about a login interface. There is a drop down list on that login interface to select one of several user types. The 'log in' button is calling an action to validate the login data in the login controller.
Now, if the login data for user type A is valid, I want to call controllerA. If login data for user type B is valid, I want to call controllerB.
But I know that calling a controller from another controller is not wise.
Then, is there another idea on how to do this login mechanism?
Obviously I can divide the login interface into several parts, each part for each user type.
may this will help you http://www.yiiframework.com/wiki/89/module-based-login/
It seems like in your regular Login action in your Site controller, you could look at the dropdown POST, and with some simple logic validate the user credentials against the right Module/DB tables pretty easily? And just redirect to correct module's after-login url?

Send POST from php Zend-Framework site

I am currently working on a zend framework site using an ACL.
The ACL works and uses a DB for storing privaliges. What I have done so far is, on in a preDispatch I capture where the user wanted to go to, and if they need to login to get there the page displays the login form. I have also captured if a user has submitted a form and stored the data (location and form data). No problems so far.
The user submits the login form, and I then check if I have a location to send them onto, again no problems here, this works.
However I want to be able to submit the original form data now they are autherised - the only problem is, if I redirect them to the page, the call to:
$this->getRequest()->isPost()
fails as it isn't a post request.
I can forward the user to the page on sucessful login, and in the preDispatch set $_POST to the data originally captured, this works as the original POST still stands, this works but I do not think is the correct way to do this - specially the URL - obviously the page displayed is correct, the form has been submitted correctly, but the URL is of the login process.
Obviously I could change from using $this->getRequest()->isPost() but as there are large amounts which would need changing I was hoping not to have to do this.
The way it's done usually (seen this on many sites), would be to store the form data and requested action in session, then redirect the user to a login page. When login is authorized, you read the session for any pending action, reload the form and populate it with data from session (properly clearing any pending action from session afterwards). The user would just have to click Submit again.
The other way to do this would be to use HttpClient and submit the data as POST with it.

Categories