Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6794805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:15:58+00:00 2026-05-26T18:15:58+00:00

i hope this one is an easy one to fix, what i would like

  • 0

i hope this one is an easy one to fix,

what i would like to achieve is to use one login for both consumers and admin’s

here is what i currently have in the applicationContext-security.xml file:

<authentication-manager alias="authenticationManager">
    <!-- DAO Based Security -->
    <authentication-provider>
        <password-encoder hash="sha-256" />
        <jdbc-user-service data-source-ref="dataSource"
            users-by-username-query="SELECT A.user_name AS username, A.consumer_password AS password, A.enabled AS enabled FROM consumer A where A.user_name=?"
            authorities-by-username-query="SELECT A.username as username, A.password as password, R.name as authority FROM admin A, roles R WHERE A.roles=R.id AND A.username=?"/>
    </authentication-provider>
</authentication-manager>

the login works fine for any consumer but i am unable to login from any of the admin accounts

sql return for the admin account:

+----------+------------------------------------------------------------------+-----------+
| username | password                                                         | authority |
+----------+------------------------------------------------------------------+-----------+
| admin    | 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8 | ADMIN     |
+----------+------------------------------------------------------------------+-----------+

sql return for the consumer account:

+----------+------------------------------------------------------------------+---------+
| username | password                                                         | enabled |
+----------+------------------------------------------------------------------+---------+
| adam     | 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8 |        |
+----------+------------------------------------------------------------------+---------+
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:15:59+00:00Added an answer on May 26, 2026 at 6:15 pm

    If I understand correctly, consumers accounts are stored in consumer table and admins are stored in admin table. Why you are expecting that admins will be able to login if in users-by-username-query you query only consumers table and not admin table?

    I think the easiest way to accomplish it is to store both customers and admins in one table (let’s say user). Then you can query that table in users-by-username-query to check if user for that login exist (no matter customer or admin) and then check whether a user is customer or admin by querying roles table in authorities-by-username-query.

    Let’s say, roles table may look something like that:

    +----------+------------------------------------------------------------------+
    | username | role                                                        
    +----------+------------------------------------------------------------------+
    | adam     | customer  
    +----------+------------------------------------------------------------------+
    | admin    | admin
    +----------+------------------------------------------------------------------+
    

    Than you can ask Spring Security at any time if currently logged user is customer or admin (see http://static.springsource.org/spring-security/site/docs/3.1.x/reference/technical-overview.html#core-components , section: Obtaining information about the current user).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope this is an easy one. Using MVC4 with Entity Framework 4.1. I'am
Hope this is not a dupe. I would like to be able to do
I hope this is an easy one, but I've got a page where there's
I hope this is any easy one. I have a view that I want
I'm sure the answer to this question is an easy one (I hope). I
I hope this is a very easy one to solve. I have a crypto
I think I already know the answer to this one, but i hope maybe
I hope it's the heat, this is the second question today and it's one
hope this will be a quick easy question, I've just tried my app on
How do I achieve this:- When user types character like 'abcd' and then '>'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.