Code Monkey home page Code Monkey logo

Comments (25)

therewillbecode avatar therewillbecode commented on August 16, 2024 2

@elv1n @LaoTsing @befeltingu @Mijobar

So the issue is that the secret key you are supplying as an environment variable to your server is not 32 characters long.

I have updated the example secret in the Readme to be the correct length.

I also updated the code so that you will see a "KeySizeTooSmall" error if the server is given too short a secret. Then this invalid secret is then used to sign a JWT when user registers. Of course this doesn't work and you get a 401.

Does using a 32 character long key for the secret fix your 401 issue?

from poker-maison.

therewillbecode avatar therewillbecode commented on August 16, 2024

You need to add more characters to the key used to signing auth tokens.

This key is obtained from an environment variable called "secret" by the app.

secret=mysecretkey stack run

from poker-maison.

IvanKonevJr avatar IvanKonevJr commented on August 16, 2024

oh thank you very much

from poker-maison.

therewillbecode avatar therewillbecode commented on August 16, 2024

No problem just let me know if you have any other issues and I will help.

from poker-maison.

IvanKonevJr avatar IvanKonevJr commented on August 16, 2024

after registration:
image

from poker-maison.

IvanKonevJr avatar IvanKonevJr commented on August 16, 2024

now registration not working

from poker-maison.

therewillbecode avatar therewillbecode commented on August 16, 2024

Are you trying to reregister an account which already exists?

Try logging in.

from poker-maison.

IvanKonevJr avatar IvanKonevJr commented on August 16, 2024

no no, registration not working, new user do not added

from poker-maison.

IvanKonevJr avatar IvanKonevJr commented on August 16, 2024

why login only from localhost, i try connect to my localhost from ngrok - and request not sended ??? can you try connect throw ngrok?

from poker-maison.

therewillbecode avatar therewillbecode commented on August 16, 2024

So when you register you get a 401 and the user isn't inserted into the DB?

from poker-maison.

IvanKonevJr avatar IvanKonevJr commented on August 16, 2024

So when you register you get a 401 and the user isn't inserted into the DB?

Yes it is

from poker-maison.

IvanKonevJr avatar IvanKonevJr commented on August 16, 2024

and how to add bots to game?

from poker-maison.

IvanKonevJr avatar IvanKonevJr commented on August 16, 2024

So when you register you get a 401 and the user isn't inserted into the DB?

Yes it is

i found and fix problem with registration

from poker-maison.

therewillbecode avatar therewillbecode commented on August 16, 2024

So what was causing the problem?

from poker-maison.

IvanKonevJr avatar IvanKonevJr commented on August 16, 2024

a problem is a not correct setting urls in profile... and how to add bots to game? and redis do not used?

from poker-maison.

Mijobar avatar Mijobar commented on August 16, 2024

Also having the same issue... Why I click register is doesn't do anything my guess is it's not saving to redis server?

michael@michael-HP-Pro3500-Series:~/Desktop/ten-poker-master/server$ stack run
"couldn't parse redishost from env default used"
"REDIS config: "
ConnInfo {connectHost = "localhost", connectPort = PortNumber 6379, connectAuth = Nothing, connectDatabase = 0, connectMaxConnections = 50, connectMaxIdleTime = 30s, connectTimeout = Nothing, connectTLSParams = Nothing}

from poker-maison.

IvanKonevJr avatar IvanKonevJr commented on August 16, 2024

yes this is is write in log

from poker-maison.

Mijobar avatar Mijobar commented on August 16, 2024

@LaoTsing is the default redis ConnInfo good? If no, can you give me an example and where i need to put it? Thanks!

from poker-maison.

therewillbecode avatar therewillbecode commented on August 16, 2024

@Mijobar The default redis ConnInfo is good if you are running redis on localhost on port 6379.

These are the default settings redis uses when you run redis-server.

If you for some reason need to change the defaults the app uses then you would start by looking here as this where the default configuration is set.

from poker-maison.

IvanKonevJr avatar IvanKonevJr commented on August 16, 2024

@therewillbecode why redis not used automatically?

from poker-maison.

IvanKonevJr avatar IvanKonevJr commented on August 16, 2024

@LaoTsing is the default redis ConnInfo good? If no, can you give me an example and where i need to put it? Thanks!

if you used redis say me how)

from poker-maison.

DavidRSeWell avatar DavidRSeWell commented on August 16, 2024

@therewillbecode Really awesome project!
I am having a similar issue it seems. I am not too familiar with the redis / postgres workflow so it is probably something small. Similar to Lao when I create a user I get a 401 but the user gets created I can see in the postgres db. I also get a 401 when trying to login with that user I just created.
This the key I am using
secret="tenpokersupersecretkey123"
I am not sure how to debug this. Any suggestions?
It seems like maybe it didnt like the password I provided because the password I used to register is ignored and a random one is set in the db. Unless it is just storing the password safely.

from poker-maison.

elv1n avatar elv1n commented on August 16, 2024

So what was causing the problem?

I have got the same problem, the user saves into DB but then cannot authorize it.
Redis is on 6379 and responding for 'redis-cli ping'

❯ stack run
"Redis host name from env is: "
"127.0.0.1"
"REDIS config: "
ConnInfo {connectHost = "127.0.0.1", connectPort = PortNumber 6379, connectAuth = Nothing, connectDatabase = 0, connectMaxConnections = 50, connectMaxIdleTime = 30s, connectTimeout = Nothing, connectTLSParams = Nothing}
[Debug#SQL] SELECT "id", "name" FROM "tables" WHERE ("name"=?) LIMIT 1; [PersistText "Black"]
[Debug#SQL] SELECT "id", "name" FROM "tables" WHERE ("name"=?) LIMIT 1; [PersistText "Black"]
[Debug#SQL] UPDATE "users" SET "available_chips"=? WHERE ("available_chips"<?); [PersistInt64 200000,PersistInt64 200000]
"Socket server listening on 5000"
OPTIONS /register
  Accept: */*
  Status: 200 OK 0.000024s
[Debug#SQL] SELECT "id", "username", "email", "password", "available_chips", "chips_in_play", "created_at" FROM "users" WHERE ("email"=?) LIMIT 1; [PersistText "test@testcom"]
[Debug#SQL] SELECT "id", "username", "email", "password", "available_chips", "chips_in_play", "created_at" FROM "users" WHERE ("username"=?) LIMIT 1; [PersistText "elvin3"]
[Debug#SQL] INSERT INTO "users"("username","email","password","available_chips","chips_in_play","created_at") VALUES(?,?,?,?,?,?) RETURNING "id"; [PersistText "test",PersistText "test@elvintestcom",PersistText "\154\180\210\STXAr\200FoXB\241l\"\185EbfAkq\ETX\DC1\189\140Z\148\199\159#1\187",PersistInt64 3000,PersistInt64 0,PersistUTCTime 2020-04-15 19:02:51.917578 UTC]
POST /register
  Request Body: {"newUsername":"test","newUserEmail":"[email protected]","newUserPassword":"test"}
  Accept: application/json, text/plain, */*
  Status: 401 Unauthorized 0.020263s
[Debug#SQL] UPDATE "users" SET "available_chips"=? WHERE ("available_chips"<?); [PersistInt64 200000,PersistInt64 200000]

from poker-maison.

therewillbecode avatar therewillbecode commented on August 16, 2024

Also having the same issue... Why I click register is doesn't do anything my guess is it's not saving to redis server?

michael@michael-HP-Pro3500-Series:~/Desktop/ten-poker-master/server$ stack run
"couldn't parse redishost from env default used"
"REDIS config: "
ConnInfo {connectHost = "localhost", connectPort = PortNumber 6379, connectAuth = Nothing, connectDatabase = 0, connectMaxConnections = 50, connectMaxIdleTime = 30s, connectTimeout = Nothing, connectTLSParams = Nothing}

This is not an issue. All it says is - you didn't pass in envinornment variables to override the Redis settings so we are going to use the defaults.

from poker-maison.

DavidRSeWell avatar DavidRSeWell commented on August 16, 2024

@therewillbecode That seemed to do it for me. Thanks!

from poker-maison.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.