`

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

    How to get current user of SharePoint 2013

    WordPress 2.7 Cookbook.pdf

    How to do it 216 How it works 217 There's more... 217 Managing who Sees Ads 218 Getting ready 218 How to do it 219 How it works 220 There's more... 220 Advanced conditions 221 Inserting ads ...

    CakePHP 1.3 Application Development Cookbook.pdf

    details saved after a successful login, and show us how to get this user information. The sixth recipe shows a more complex authorization technique that relies on route prefixes. The seventh recipe ...

    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....

    Grails: A Quick-Start Guide

    We’ll dig into Grails’ powerful view technology, Groovy Server Pages, and see how we can easily leverage the help given to us by scaffolding to create custom user interfaces faster than you would ...

    Application Development with Parse using iOS SDK

    Understand user creation with login process and user roles to secure data on Parse iOS cloud Get to grips with the different ways to handle errors along with securing your data on cloud Approach A ...

    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 ...

    Flask By Example.pdf 最新 原版

    Extend your applications to build advanced functionality, such as a user account control system using Flask-Login Learn about web application security and defend against common attacks, such as SQL ...

    Flask Framework Cookbook.pdf 最新 原版

    You will see how to write an admin interface followed by the debugging and logging of errors. Finally, you will learn about different deployment and post-deployment techniques on platforms such as ...

    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 ...

    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 ...

    基于JAVA的BBS论坛的设计与实现.doc

    Common user system can complete the user login, exit, post, reply, registration, modify the post, delete my post, modify passwords and other functions. The administrator can manage the board, ...

    毕业设计-基于bs的qq聊天软件的设计与实现.doc

    along with the network application more and more widely, how to quickly get the information they need to have become nowadays must solve the problem.To develop a chat room, first of all, in our mind,...

    Securing PHP Web Applications.pdf

    How to Sanitize Data to Prevent Buffer Overflows 48 Patch the Application 49 Verify That We’re Running the Latest Stable Versions 49 Check Variable Sanitation 51 Wrapping It Up 52 Chapter 5 Input ...

    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...

Global site tag (gtag.js) - Google Analytics