Geting Current logged user details for jhi_persistenet_audit_event tableHow to select the nth row in a SQL database table?MyISAM versus InnoDBMySQL Error 1093 - Can't specify target table for update in FROM clauseHow do I restore a dump file from mysqldump?How to get a list of user accounts using the command line in MySQL?MySQL: Large VARCHAR vs. TEXT?How to shrink/purge ibdata1 file in MySQLGrant **all** privileges on databaseSQL query return data from multiple tablesHow to import an SQL file using the command line in MySQL?
What could a self-sustaining lunar colony slowly lose that would ultimately prove fatal?
Which European Languages are not Indo-European?
Why does Mjolnir fall down in Age of Ultron but not in Endgame?
In general, would I need to season a meat when making a sauce?
Is there an online tool which supports shared writing?
Have 1.5% of all nuclear reactors ever built melted down?
Teacher help me explain this to my students
How to get Data from Rasperry to Arduino?
Pirate democracy at its finest
Is Jon Snow the last of his House?
Need to understand my home electrical meter to see why bill is so high and/or if neighbor is on same meter
How should I introduce map drawing to my players?
How do I partition a matrx into blocks and replace zeros with dots?
Using credit/debit card details vs swiping a card in a payment (credit card) terminal
Leaching of copper using zinc
My employer faked my resume to acquire projects
Where's this lookout in Nova Scotia?
Is the Indo-European language family made up?
How to deal with a colleague who is being aggressive?
Should breaking down something like a door be adjudicated as an attempt to beat its AC and HP, or as an ability check against a set DC?
Gladys goes shopping
Realizing cohomology classes by submanifolds
Best material to absorb as much light as possible
Construct a word ladder
Geting Current logged user details for jhi_persistenet_audit_event table
How to select the nth row in a SQL database table?MyISAM versus InnoDBMySQL Error 1093 - Can't specify target table for update in FROM clauseHow do I restore a dump file from mysqldump?How to get a list of user accounts using the command line in MySQL?MySQL: Large VARCHAR vs. TEXT?How to shrink/purge ibdata1 file in MySQLGrant **all** privileges on databaseSQL query return data from multiple tablesHow to import an SQL file using the command line in MySQL?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am working with jhipster. I need to create a new table for auditing my database changes and link it with the default jhi_persistenet_audit_event table generated by the Jhipster. How I can get the current logged user record from the jhi_persistenet_audit_event table to link that id to my new table?
mysql spring-boot jhipster
add a comment |
I am working with jhipster. I need to create a new table for auditing my database changes and link it with the default jhi_persistenet_audit_event table generated by the Jhipster. How I can get the current logged user record from the jhi_persistenet_audit_event table to link that id to my new table?
mysql spring-boot jhipster
add a comment |
I am working with jhipster. I need to create a new table for auditing my database changes and link it with the default jhi_persistenet_audit_event table generated by the Jhipster. How I can get the current logged user record from the jhi_persistenet_audit_event table to link that id to my new table?
mysql spring-boot jhipster
I am working with jhipster. I need to create a new table for auditing my database changes and link it with the default jhi_persistenet_audit_event table generated by the Jhipster. How I can get the current logged user record from the jhi_persistenet_audit_event table to link that id to my new table?
mysql spring-boot jhipster
mysql spring-boot jhipster
asked Mar 24 at 3:41
akalankaakalanka
32
32
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Solution 1: Principal principal
@RequestMapping(value = "/", "")
public String start(Principal principal, Model model)
String currentUser = principal.getName();
return currentUser;
Solution 2: Authentication authentication
@RequestMapping(value = "/", "")
public String currentUserName(Authentication authentication)
return authentication.getName();
Solution 3: SecurityContextHolder
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (principal instanceof UserDetails)
String username = ((UserDetails)principal).getUsername();
else
String username = principal.toString();
Details 1 Details 2
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320534%2fgeting-current-logged-user-details-for-jhi-persistenet-audit-event-table%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Solution 1: Principal principal
@RequestMapping(value = "/", "")
public String start(Principal principal, Model model)
String currentUser = principal.getName();
return currentUser;
Solution 2: Authentication authentication
@RequestMapping(value = "/", "")
public String currentUserName(Authentication authentication)
return authentication.getName();
Solution 3: SecurityContextHolder
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (principal instanceof UserDetails)
String username = ((UserDetails)principal).getUsername();
else
String username = principal.toString();
Details 1 Details 2
add a comment |
Solution 1: Principal principal
@RequestMapping(value = "/", "")
public String start(Principal principal, Model model)
String currentUser = principal.getName();
return currentUser;
Solution 2: Authentication authentication
@RequestMapping(value = "/", "")
public String currentUserName(Authentication authentication)
return authentication.getName();
Solution 3: SecurityContextHolder
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (principal instanceof UserDetails)
String username = ((UserDetails)principal).getUsername();
else
String username = principal.toString();
Details 1 Details 2
add a comment |
Solution 1: Principal principal
@RequestMapping(value = "/", "")
public String start(Principal principal, Model model)
String currentUser = principal.getName();
return currentUser;
Solution 2: Authentication authentication
@RequestMapping(value = "/", "")
public String currentUserName(Authentication authentication)
return authentication.getName();
Solution 3: SecurityContextHolder
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (principal instanceof UserDetails)
String username = ((UserDetails)principal).getUsername();
else
String username = principal.toString();
Details 1 Details 2
Solution 1: Principal principal
@RequestMapping(value = "/", "")
public String start(Principal principal, Model model)
String currentUser = principal.getName();
return currentUser;
Solution 2: Authentication authentication
@RequestMapping(value = "/", "")
public String currentUserName(Authentication authentication)
return authentication.getName();
Solution 3: SecurityContextHolder
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (principal instanceof UserDetails)
String username = ((UserDetails)principal).getUsername();
else
String username = principal.toString();
Details 1 Details 2
answered Mar 24 at 5:11
Patel RomilPatel Romil
878415
878415
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320534%2fgeting-current-logged-user-details-for-jhi-persistenet-audit-event-table%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown