How to get the User.ID After creating it programmatically for SSO integration on LDAP

Added by Seth DeSantis about 1 year ago

I am trying to setup SSO, and can create user's easily, but I have no way of obtaining the ID.

  1. Generates a new autologin token and returns its value
    def generate_autologin_token
    token = Token.create!(:user_id => id, :action => 'autologin')
    return token.to_s
    results in:
    Mysql2::Error: Column 'user_id' cannot be null: INSERT INTO `tokens` (`user_id`, `action`, `value`, `created_on`, `updated_on`) VALUES (NULL, 'autologin', '55c6b96a13a5de291234ea447c2ecfbe4a63b388', '2020-09-27 00:18:13', '2020-09-27 00:18:13')

Which is valid as there is no user_ID as it states NULL.

Any help appreciated, thank you.