Hi Guys I'm new in ColdBox and i want to setup a l...
# box-products
r
Hi Guys I'm new in ColdBox and i want to setup a login flow with cbsecurity i'm not able to connect database with cbsecurity for authenticate the user
a
You mean you want to hook cbSecurity to use an existing user database table?
What have you tried so far?
r
Yes but no idea how to do
a
OK - so https://cbauth.ortusbooks.com/ is what cbSecurity uses
So you create a service which implements this signature and can have whatever code you want in it. https://cbauth.ortusbooks.com/iuserservice
then in ColdBox.cfc tell cbAuth what class to use:
moduleSettings = { cbauth: { userServiceClass: "MyUserService" }}
r
@aliaspooryorik thanks, let me try i'll ask if anything needed
what exactly I am doing is I want to make a rest API using the JWT token default demo on Auth.cfc the code written is
jwtAuth().attempt( rc.username, rc.password );
in login method and my UserService class has mockUsers i want to replace with mockuser exact the user class that has in database
a
OK, so
jwtAuth().attempt( rc.username, rc.password );
delegates to
cbSecurity.getAuthService().authenticate( arguments.username, arguments.password );
which then passes it onto
getUserService().isValidCredentials( arguments.username, arguments.password )
so whatever you implement as your isValidCredentials method is what it'll use.
Not sure what the issue is to be honest. You say "my UserService class has mockUsers", so why can't you change you UserService class to get from the database?
r
Ok I'll try with my database