Skip to content

Commit

Permalink
fix: oidc params issue (#2190)
Browse files Browse the repository at this point in the history
where `params` was expected to have accessor methods, but was actually a hash

also resolved #2183
  • Loading branch information
phuang26 authored Sep 30, 2024
1 parent 7056019 commit caedd88
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
14 changes: 7 additions & 7 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -373,23 +373,23 @@ def text_templates
end

def self.from_omniauth(params)
user = find_by(email: params&.email&.downcase)
user = find_by(email: params[:email]&.downcase)
if user.present?
providers = user.providers || {}
providers[params&.provider] = params&.uid
providers[params[:provider]] = params[:uid]
user.providers = providers
user.save!
else
user = User.new(
email: params&.email,
first_name: params&.first_name,
last_name: params&.last_name,
email: params[:email]&.downcase,
first_name: params[:first_name],
last_name: params[:last_name],
password: Devise.friendly_token[0, 20],
)
end

if params&.groups&.length&.positive?
params.groups.each do |group|
if (params[:groups] || []).length&.positive?
(params[:groups] || []).each do |group|
name = group.split(':')
if name.size == 3
group = Group.find_by(first_name: name[2], last_name: name[1])
Expand Down
11 changes: 10 additions & 1 deletion app/packs/src/apps/omniauthCredential/LoginOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ import uuid from 'uuid';
import UserStore from 'src/stores/alt/stores/UserStore';
import UserActions from 'src/stores/alt/actions/UserActions';

function omniauthLabel(icon, name) {
if (icon) {
return (
<img src={`/images/providers/${icon}`} alt={name} title={name} />
);
}
return name;
}

export default class LoginOptions extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -41,7 +50,7 @@ export default class LoginOptions extends Component {
<Col key={uuid.v1()} md={12 / keys.length} className="login-options">
<Button href={`/users/auth/${key}`}>
Login with &nbsp;
<img src={`/images/providers/${omniauthProviders[key].icon}`} className="kit-logo" alt={key} title={key} />
{omniauthLabel(omniauthProviders[key].icon, omniauthProviders[key].label || key)}
</Button>
</Col>
));
Expand Down

0 comments on commit caedd88

Please sign in to comment.