Hi,
Whatever works best for you. Having an alternative user style while still having statistics is a good thing to have in any case.
-dev
Hi,
Whatever works best for you. Having an alternative user style while still having statistics is a good thing to have in any case.
-dev
Also I think OAuth table need access_token_expires_at column too (timestamp type).
Edit: wait, how can I work with timestamp in my lua code? I ended with bigint column, because it’s easy to take and compare with os.time()
Hi,
You can create a TIMESTAMP column type and use the core.mysql.timestamp() method: https://develephant.github.io/coronium-core-docs/server/modules/mysql/#timestamp
You can then use normal MySQL queries to work with them. But using os.time() can work too.
-dev
core.mysql.timestamp() gives me current timestamp?
How can I create timestamp from some date in UNIX format? (like core.mysql.timestamp(seconds) - this doesn’t work)
Hi,
I’ll add some additional methods, but in Lua:
UTC (which is what you should use for MySQL timestamps):
local d = os.date('!%F %T', 1516633468) print(d) -- 2018-01-22 15:04:28
-dev
Hi,
Quick question, are the FB access token expiry times in UNIX format by default?
-dev
Yes, response looks like :
{ "expires\_at": 1352419328, "user\_id": "1207059", //some other fields }
Hi,
You’ve probably rolled your own solution by now, but the 2.4.0 release has a new Users API and OAuth API.
Take a look at the following links for more information regarding your use case:
https://develephant.github.io/coronium-core-docs/server/modules/users/api/
https://develephant.github.io/coronium-core-docs/server/modules/users/oauth/
https://develephant.github.io/coronium-core-docs/server/modules/users/oauthusers/
-dev
Yes, thats interesting.
However your example of logging via Facebook is not full, token validation is required to make sure that user is valid.
Validation is just simple call to facebook API, you can see examples how it was done in Parse server:
https://github.com/parse-community/parse-server/blob/5813fd0bf8350a97d529e5e608e7620b2b65fd0c/src/Adapters/Auth/facebook.js
https://github.com/parse-community/parse-server/blob/5813fd0bf8350a97d529e5e608e7620b2b65fd0c/src/Adapters/Auth/google.js
Interesting that you are also publisher of parse plugin on corona marketplace, didn’t notice it before
Hi,
From your previous posts, I assumed you were wanting to check that yourself on the server-side. ;)
I will look at deeper integration in the near future.
-dev
Yeah, but I see you added oauth to client module too:
http://docs.coroniumcore.com/client/modules/users/oauth/
Anyway, I will try to integrate your changes with my code and probably share sample project
Hi,
Thats a false assumption.
I get id from user external service and use it to automatically create a user account, using the user module in coronium core.
You can also make your own user table, with the obvious limitations you’ve mentioned, the choice is yours.
You are clearly interested in coronium core so I suggest you dive in and test drive it to find out what can be done and not
These days you even have a free trial period
Theory will only get you so far and I suspect people on the forum are more inclined to help with actual code problems than theoretical cases like this one where you can find the answer yourself by firing up coronium core and try it out.
CC is a great product, you wont be disappointed.
I already have coronium server installed, I just experimenting with modules for now.
I get id from user external service and use it to automatically create a user account, using the user module in coronium core.
So my actual code problem is that password is required. Do you set up some default password to create user from user module?
Edit : I also figured out that core.users object is available on api side. But the problem is that this method is asynchronous: it require listener. And api method should return response in synchronous way: I don’t have possibility to “wait” until listener fired
Hi,
Yeah I generate the user password on user creation together with a user hash id which is stored with user data.
I know there is no wait functionailty in lua but how come you cant wait for the reply before “moving on” ? Everything in corona in regards to network calls are async so this is one you need to code according to.
It is possible to create you own “wait” logic using booleans but i find it more hassle than calling functions from async callbacks.
I mean I can’t wait on server side (in coronium api)
So code I want:
function api.upsertUser(params) --validate params code --check if user exist if (userNotExist) then core.users.create({username = params.username, password="some default password"}, myListener) else core.users.login({...}, myListener) end --I should return value from api function, return from listener will not work return {} end
yeah you can
check if user exist and wait for callback on callback evaluate result and either create user or login
you can also do a 2-in-1 call like this
login user (our own core api call) on server, if user dont exist, create, else login return reply to client
the latter is slightly more efficient but it wont matter if you do 2-3 api calls during user creation or just 1.
also, if you are using digitalocean, there is no practical api call limit to your droplet.
hope that makes sense. not writing code here just describing logic.
Yeah, thanks
But I think I’ll make custom logic on api side to avoid multiple calls from client.
then async calls wont be an issue for you
Hi,
What columns do you need for Facebook login (its been a while since i’ve used it)? Perhaps having support for Facebook login in the users system would be a good idea,
There is a server-side users module, but it requires a different approach, and if not handled properly could mess up the users system, so I never documented it for safety. That may be a good way to add custom users though. I could add documentation if you’re interested in trying that approach. You would then need to write your own custom server-side login logic.
The “coronium” database is not safe from updates, as new features or adjustments might be made in the future, so its best not to change it.
-dev
For now I trying to build flexible OAuth system (at least for Facebook and Google).
I use Facebook user Id for now
function api.createOrUpdateUser(params) if (params == nil) then return core.error("provide parameters!") end if (type(params.loginSystem) ~= "string" or not checkLoginSystem(params.loginSystem)) then return core.error("loginSystem missed or unknown") end if (params.userId == nil) then return core.error("User id is required") end local userId = core.mysql.escape(params.userId) local lSystem = core.mysql.escape(params.loginSystem) local record, err = core.mysql.selectOne(DB\_NAME, { tbl = USERS\_TABLE, where = "externalId = " .. userId .. " and loginSystem = " .. lSystem, columns = { "id" } }) if (err) then return toGeneralError(err) end local isUserExist = record ~= nil print("user exist?",isUserExist) if (not isUserExist) then core.mysql.insert(DB\_NAME, { tbl = USERS\_TABLE, values = { username = userId, loginSystem = lSystem, data = core.json.encode({ counter = 1 }) } }) end ...