File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
lib/generators/auth/templates/models Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ #= User
4+ #
5+ # A person who has an account on the site (via Google Cloud Identity Platform).
6+ class User < ApplicationRecord
7+ validates :identity_platform_id , presence : true , uniqueness : true
8+
9+ def self . from_identity_token ( token )
10+ return unless token . valid?
11+
12+ find_or_initialize_by ( identity_platform_id : token . subject ) . tap do |user |
13+ user . update! token . payload . slice ( :name , :email )
14+ end
15+ end
16+ end
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ class CreateUsers < ActiveRecord ::Migration [ 7.0 ]
4+ def change
5+ create_table :users do |t |
6+ t . string :email
7+ t . string :name
8+ t . string :identity_platform_id , null : false
9+
10+ t . timestamps
11+
12+ t . index %i[ identity_platform_id ] , name : :UK_user_identity_platform , unique : true
13+ end
14+ end
15+ end
16+
You can’t perform that action at this time.
0 commit comments