CS-Cart - Change login URL in notification email - cs-cart

I was testing the user account registration system.
When new users sign up for accounts, they are sent a notification email. The email, by default, includes this line:
Login URL: http://mystore.com/
The problem is, that's not the login URL. The login URL is http://mystore.com/login/
The URL seems to be generated by this line in the email template (profiles_info.tpl):
{if $user_data.company_id}{"?company_id=`$user_data.company_id`"|fn_url:'C':'http'}{else}{""|fn_url:'C':'http'}{/if}
But I don't understand how fn_url works (there doesn't seem to be any documentation). So how can I fix the login URL - or what would be the best way to do so?

this function define in /app/functions/fn.common.php
change:
{if $user_data.company_id}{"?company_id=$user_data.company_id"|fn_url:'C':'http'}{else}{""|fn_url:'C':'http'}{/if}
to this:
{''|fn_url:'C':'http'}login/

The login url in CS-Cart can be generated this way: fn_url("auth.login_form"). The auth controller handles the authentication, within this controller, there is a login_form mode, which will display the login screen for the user.
If you would like to display the link in a Smarty template, you can use this code: {"auth.login_form"|fn_url}. This is the proper way, to link the login form, because if you hardcode the /login/ into the template, and later you would like to use a different URL for the login, or you want to use multi-language SEO URL-s, it will fail.
So the correct code in the e-mail template will look like this:
{if $user_data.company_id}{"auth.login_form?company_id=`$user_data.company_id`"|fn_url:'C':'http'}{else}{"auth.login_form"|fn_url:'C':'http'}{/if}

Related

Get token parameter inside of .ConfirmationURL to reset password on reset password template supabase

i need get the token to reset password user in the reset password email template becuase i will send this token in firebase deep link but the parameter .ConfirmationURL has url with more information, i just need get the token, there is the posibility of get this parameter with a especific name inside the template as .ConfirmationURL? thanks
Update
i have configuration all parameter as shown in the documentation:
Additional redirect URLs
FLutter initialization
await Supabase.initialize(
url: supabaseUrl,
anonKey: supabaseAnnonKey,
authCallbackUrlHostname: 'login-callback',
debug: true,
localStorage: SecureLocalStorage(),
);
if i send the reset email this send fine with a link as the picture, the content of link is this
https://xxxxxxxxxxxxx.supabase.co/auth/v1/verify?token=kiaknuztglhtdcynoaog&type=recovery&redirect_to=https://localhost:3000
Now if i click in the link since the phone, it does not redirect me to the application, but the user is logged in the supabase panel automatically.
I dont understand what i do wrong and for this reason i try use firebase to deep links but the access_token parameter cannot be accessed. so i think that i need help in the last step
Update 2
Finally works, i use the parameter redirectTo inside of resetPasswordEmail and the deeplink connect with the app:
response = await clientSupabase.auth.api.resetPasswordForEmail(
datauser.email,
options: AuthOptions(redirectTo: Credentials.myAuthRedirectUri),
);
Aditional i use the next configuration in setting configuration authentication supabase:
In flutter code i use the next method in the login page, this method just is called when the user clik the link in the reset password mail:
#override
void onReceivedAuthDeeplink(Uri uri) {}
The problem seems that you are redirecting to localhost:3000 upon sign up, but you actually want to redirect to the deeplink you have setup.
When you signup, you can provide a options with redirectTo set as the deeplink you have setup within Supabase's console to redirect the user to a certain page instead of the default site URL.
Supabase.instance.client.auth
.signUp('email', 'password', options: AuthOptions(redirectTo: 'io.supabase.flutterquickstart://login-callback/'));

Laravel redirect to intended page after login/register

I am new to Laravel. I am using Laravel's auth controllers for login/register on my website. After login/register, it will redirect to a dashboard. This is fine.
The problem is when the user (not logged in) submits a particular form. The form submission will take the user to a protected page. The auth system will intercept this (if not logged in) and ask for the user to login and the user can sign in. But after the sign in it won't get redirected to the actual destination. Instead, it goes back to the previous page. I tried the redirectto->intended() way in the middleware. It still does not work.
Found the solution. Use HTTP session. I am not sure if this is the best method.
POST the form to a route which doesn't need authentication
Validate and store the form data in the session using the controller
Redirect to the protected route where the auth will intercept and ask the user to login
After successful login, redirect to the original destination page using return redirect()->intended('defaultPage');
Access the form data from session inside the blade view
I am not storing any sensitive data in session. I have no idea how secure this method is.
If you have any suggestions please post.

How to redirect user back to the next request after login with sentry in laravel 5.3

I am using sentry to authenticate users in laravel 5.3. When the user clicks auth protected route is redirect to the login form. After login, the user is redirected to home page.
How can I configure sentry in manner that the authenticated user is not redirected back to home page but instead to the original destination before login. Kindly assist I seem not to figure it out.
You can use a function called intended
return redirect()->intended('dashboard');
The intended method on the redirector will redirect the user to the URL they were attempting to access before being intercepted by the authentication middleware. A fallback URI may be given to this method in case the intended destination is not available.
https://laravel.com/docs/5.3/authentication#authenticating-users
Maybe this may help you --
You can try giving the url something like this localhost:8000/something?url=anythingelse so that after login change the redirect path to $_GET['url'].
Use a form rather than link to go to login page. Try this --
<form method="GET" url="{{ url('/some') }}?{{ Request::path() }}" id="login"></form>
Login

Redirect to a route after clicking a button

How can I redirect to a route after clicking a button?
What I have done is this, using url() . Isn't this dangerous without passing a token?
Login
You should use the helper "route".
Like this:
Login
And, in your routes.php file, define that route name:
Route::get ('/movies/login',['uses'=>'CONTROLLER#METHOD'])->name('ROUTE_NAME');
Done! ;)
To redirect to route by it's name, you should use route():
Login
And yes, it's safe, since you're not sending any form data here.
https://laravel.com/docs/5.3/csrf
If you just want to redirect to the login page, then this should be fine, access tokens usually used with RESTful applications (because there is no session); if you are just navigating an user inside your website, then the laravel session handler should do most of it for you,
otherwise
You shouldn't handle login with GET.
Build a form, and POST it to a given route, in which you can validate the input parameters and then redirect to a given url from the server side.
This way you can add hidden inputs with CSRF tokens or other tokens.

Manage Login Redirection in Pyrocms

I need to manage login in such a way that it should redirect the control after successful login to the page which call login method in pyrocms.
By default it return control to Home Page. for example i want to go gallery page but it require user to be logged in so it will redirect control to the login page and now i want to redirect the control back to the gallery page once the user successful logged in.
Finally, i have come with the exact solution which is working correctly for me.
Whenever user try to view the gallery page(restricted page) which require user login, we have to only assign the URL where we want to redirect after successful login in $redirect_to in the controller method:
$this->session->set_userdata('redirect_to',$redirect_to);
Then it will automatically redirect the control to the desired page. Because in the users controller the login function is developed in such a way that:
$redirect_to = $this->input->post('redirect_to') ? $this->input->post('redirect_to') : $this->session->userdata('redirect_to');
Hopefully this will help you sometime

Resources