logo
down
shadow

Symfony remember me login datetime needed


Symfony remember me login datetime needed

By : Renos Zannettos
Date : November 19 2020, 01:01 AM
help you fix your problem For my web application I need to know when a user logged in, this works fine through the normal login form. I created an AuthenticationHandler that stores the current datetime in the user object on success. But when the user decides to use the "remember me" functionality this doesn't work the next time it "logs in", it doesnt pass the onAuthenticationSuccess function. , You can add a listner
service.yml
code :
services:
    login_listener:
        class: 'Acme\YourBundle\Listener\LoginListener'
        arguments: ['@security.context', '@doctrine']
        tags:
            - { name: 'kernel.event_listener', event: 'security.interactive_login' }
<?php

namespace Acme\YourBundle\Listener;

use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\Security\Core\SecurityContext;
use Doctrine\Bundle\DoctrineBundle\Registry as Doctrine;


class LoginListener
{
    private $securityContext;
    private $em;

    /**
     * Constructor
     * 
     * @param SecurityContext $securityContext
     * @param Doctrine        $doctrine
     */
    public function __construct(SecurityContext $securityContext, Doctrine $doctrine)
    {
        $this->securityContext = $securityContext;
        $this->em              = $doctrine->getEntityManager();
    }

    /**
     * 
     * @param InteractiveLoginEvent $event
     */
    public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
    {
        if ($this->securityContext->isGranted('IS_AUTHENTICATED_FULLY')) {
            // here your code
        }elseif ($this->securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
            // here your code
        }

    }
}


Share : facebook icon twitter icon
how to record login date which members login by remember me?

how to record login date which members login by remember me?


By : Thành Lê Tiến
Date : March 29 2020, 07:55 AM
Does that help You should do that in a custom web user component that extends from CWebUser. Then you can override afterLogin() there and store the login date even for cookie logins.
Symfony force login and remember me

Symfony force login and remember me


By : emreisin
Date : March 29 2020, 07:55 AM
like below fixes the issue Use RemeberMeToken and there is no need to set it manually in session, just fire interactive_login event:
code :
// Auto Authenticate User
$firewall = 'user_firewall';
$key = $this->getParameter('secret'); //from parameters.yml
$token = new RememberMeToken($user, $firewall, $key);
$this->get('security.token_storage')->setToken($token);

$this->get('event_dispatcher')->dispatch(
    SecurityEvents::INTERACTIVE_LOGIN,
    new InteractiveLoginEvent($request, $token)
);
        yourProviderKey: # oauth i guess
            remember_me: true
        remember_me:
            secret:   '%secret%'
            lifetime: 604800 # 1 week in seconds
            path:     /
            #always_remember_me: true # optional
Google Chrome didn't remember login credentials in my login form

Google Chrome didn't remember login credentials in my login form


By : André Oliveira
Date : March 29 2020, 07:55 AM
may help you . That means that you probably missing either field name or field ID
To be sure that it will work in all browsers be sure to provide both, even if name should be enough.
symfony 3.3 programmatically login a user with remember me feature

symfony 3.3 programmatically login a user with remember me feature


By : millymike
Date : March 29 2020, 07:55 AM
seems to work fine I want to login a user after registration successfully. Currently the solution I found online is login a user in a session basis. But I need the "remember me" feature. My research lead me to the , Here I had my own answer. First, login user with following snippet
code :
    $user = new \AppBundle\Security\User\EndUser($id, $userKey, $username, $password, $salt, $roles);
    $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
    $this->container->get('security.token_storage')->setToken($token);
    $this->container->get('session')->set('_security_main', serialize($token));
    $file   = sprintf("%s/config/security.yml", $this->container->getParameter('kernel.root_dir'));
    $parsed = Yaml::parse(file_get_contents($file));
    $options = $parsed['security']['firewalls']['main']['remember_me'];

    $endUserProvider = $this->container->get('AppBundle\Security\User\EndUserProvider');
    $secret = $providerKey = $this->container->getParameter('secret');
    $service = new TokenBasedRememberMeServices(array($endUserProvider), $secret, $providerKey, $options, null);
    $r = new \ReflectionMethod($service, 'onLoginSuccess');
    $r->setAccessible(true);
    $r->invoke($service, $request, $response, $token);
Symfony 3 login is instantly forgotten unless "Remember Me" is used

Symfony 3 login is instantly forgotten unless "Remember Me" is used


By : user1509393
Date : March 29 2020, 07:55 AM
will help you We've updated a base project from Symfony 2.8 to 3.4. This has largely gone well, blah blah, but I've noticed quite an important issue. , In your security.yml, remove:
code :
logout_on_user_change:  true
Related Posts Related Posts :
  • How to make a sitemap using zend framework 1
  • Laravel: array to Model with relationship tree
  • $_SERVER['DOCUMENT_ROOT'] vs $path = $_SERVER['DOCUMENT_ROOT']
  • What is the best way to store multiple checkbox values in the database and work with it later on
  • Why does foreach copy the array when we did not modify it in the loop?
  • Receive Jquery/Ajax Post Request in PHP
  • How to better use the if(!empty()){ //codes} statement
  • PHP error mysql_close() boolean given
  • Move an image file from one server to another using PHP
  • PHP: Encoding non ISO-8859-1 charactrers into utf8
  • Handling MySQL errors in PHP
  • Object orientated mysql num_rows query in one line
  • Remove not closed html elements from end of text
  • Generate random ENUM value [PHP, MySQL]
  • Deleting data from table using jQuery and SQL
  • How to make sure the constructor is executed when I'm trying to reach a static property?
  • Trying to understand arrow next to PHP function
  • Form using external php file to show "Sucess"
  • WooCommerce - new shipping method - how to query individual product weights
  • Common integer representation over variable casting?
  • PHP - Prevent client from tampering the ID of a form
  • unexpected T_PUBLIC error
  • Types of testcases in PHPUnit
  • keeping a LDAP user logged in with PHP session
  • Detect if browser supports WebP format? (server side)
  • real_escape_string not cleaning up entered text
  • E-commerce products filter
  • Why having more than one test method in a file using Laravel raises error?
  • PHP Escaped special characters to html
  • Basic prepared statement not INSERTING
  • PHP combobox not showing in HTML table
  • MySql PHP row request to variable
  • Join two tables with one table has multiple rows matching
  • Looping through users with Instagram API requests is REALLY slow
  • Unable to add 30 days to date within loop
  • Return from mysqli_query() into array
  • php rename() function returns "No such file or directory" error
  • form submit inside navigation menu
  • PHP: reasons to use GET and POST request at the same time?
  • Is break; required after die() php
  • little depth of session in php
  • Authentication Logon page not working using PHP and Oracle on Apache / Windows 2008
  • Magento reindexing error product flat data
  • Laravel 4: Running composer when deploying to Heroku
  • Long Polling or WebSockets
  • How to use mysqli_stmt_bind_param for integers, boolean, etc
  • Determining the content of a link
  • MYSQL and PHP update events?
  • PHP explode all square bracket
  • Transparent hexagon-masked collage using PHP GD
  • Plugins or text do NOT show up on custom wordpress template
  • inserting data into mysqli database
  • Two arguments to closure function laravel
  • UnClear image exported by ffmpeg from mp4 file
  • is the time of computer and localhost same?
  • change custom data- value after ajax post success
  • Can We Restrict PHP Variables to accept only certain type of values
  • csv file is inserting a blank row in the last of other rows into mysql table
  • How to convert special characters in xml using php?
  • Mcrypt are very confusing
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org