`

how to get login user info

阅读更多

request.getRemoteUser() 

SecurityContext context = SecurityContextHolder.getContext();

 

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

In order to log the user in automatically after signup, I discovered that Ineeded to place the SecurityContext in the session. I did this by changing
the following code in SignupController:

         // log user in automatically
         UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(user.getUsername(), user.getConfirmPassword(),user.getAuthorities());
         auth.setDetails(user);
         SecurityContextHolder.getContext().setAuthentication(auth);

To:

// log user in automatically
UsernamePasswordAuthenticationToken auth = new
UsernamePasswordAuthenticationToken(
user.getUsername(), user.getConfirmPassword(), user.getAuthorities());
auth.setDetails(user);
SecurityContext context = SecurityContextHolder.getContext();
context.setAuthentication(auth);
request.getSession().setAttribute("ACEGI_SECURITY_CONTEXT", context);

Hope this helps someone!

分享到:
评论

相关推荐

    How to Login into SharePoint 2013

    var user = web.get_currentUser(); // 加载用户属性 context.load(user); // 执行查询并处理结果 context.executeQueryAsync( function() { console.log('用户名:' + user.get_title()); console.log('...

    Login Control

    11. Do not forget to provide an event handler for the Logon so the Postback can handle the user authentication properly. 12. All rights reserved to the control author - aspnet100@yahoo....

    Rails, Angular, Postgres, and Bootstrap(Pragmatic,2016)

    In each chapter of this book, you’ll learn how these technologies can work together inside a Rails app to deliver well-performing applications that offer great user experiences. Create a usable and...

    Zend Framework 2 Application Development

    We will explore the components of this new version of the framework and discover how to use each component, the options available, and how to get the most from each component. Whilst learning ...

    Rails.Angular.Postgres.and.Bootstrap.2nd.Edition

    See how creating an advanced Postgres index for a case-insensitive search speeds up your back end - enabling you to create a dynamic user experience using Angular 2. Create reusable components that ...

    DVWA靶场搭建教程,网站搭建

    在Linux上,你可以使用apt-get(Ubuntu/Debian)或yum(CentOS/RHEL)来安装Apache、PHP和MySQL。在Windows上,你可以下载并安装XAMPP或WAMP套件。 步骤2:安装MySQL 创建一个新的数据库和用户,记下数据库名、...

    Android代码-Github非官方客户端WeGit

    How to get a APK Download WeGit from 腾讯应用宝、Google play You can download an apk from here You can also scan the below QR code to download apk in your mobile phone. Bug Q:Crush after ...

    BSD Hacks.pdf

    9. **Customizing User Configurations (HACK 9):** Here, users learn how to customize various aspects of their environment, such as terminal settings, window manager configurations, and application ...

    Intrusion Detection: Network Security beyond the Firewall

    How Hackers Get around Access Control How to Improve upon Access Control Memco SeOS APIs Impact of SeOS on Base Operating System Security SeOS Auditing Other SeOS Features Going beyond SeOS ...

    opengoo 1.3 RC1

    - bugfix: Fixed an issue with cookies that didn't allow you to login to two OpenGoo installations on the same server, or an OpenGoo installation and a Joomla installation - bugfix: Fixed some ...

    VB编程资源大全(英文源码 ASP)

    <END><br>8,下载_script.zip This 下载 counter script uses ASP file system object to get the size of the 下载 file and to track how many times a file is already 下载ed. <END><br>9,k-base.zip K ...

    VB编程资源大全(英文源码 网络)

    So 下载 the code and get involved with the News Group, help us to help you.<END><br>4 , urllink.zip User control to launch web browser and jump to URL.<END><br>5 , vbftp.zip Sample application ...

    mac4linux v_1.0

    To get started with Mac4Lin, users need to follow a series of steps outlined in the documentation. These steps cover everything from downloading and installing the pack to fine-tuning various aspects ...

    eric5-5.3.1

    how to improve eric5. If the required packages (Qt4, QScintilla2, sip and PyQt4) are not installed, please get them and install them in the following order (order is important). 1. Install Qt...

    Sending Email using MAPI - A COM DLL(sending email demo and soucecode)

    Sends the email, requires valid outlook profile name, recipient email address and a login session to send email. Steps to execute the demo project The demo project demonstrates the way you can ...

    Sakemail

    sorry =)- Minor changes to the code.1.0- Developed with WSockets 1.2 POP.Login now return a boolean depending id the user is authorized, and POP.Init return the number of new msgs.1.01- Fixed a bug ...

    hydra 7.2 win32

    consultants the possiblity to show how easy it would be to gain unauthorized access from remote to a system. THIS TOOL IS FOR LEGAL PURPOSES ONLY! There are already several login hacker tools ...

Global site tag (gtag.js) - Google Analytics