File tree 3 files changed +35
-1
lines changed
3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ def self.find_first_by_auth_conditions(conditions = {})
48
48
end
49
49
end
50
50
51
+ def after_database_authentication
52
+ if websocket_token . blank?
53
+ update_attributes ( websocket_token : SecureRandom . uuid )
54
+ end
55
+ end
56
+
51
57
def has_badge? ( type )
52
58
badges . each do |b |
53
59
return true if b . badge_type == type
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+
3
+ class AddWebsocketToken < ActiveRecord ::Migration
4
+ def up
5
+ execute <<-SQL
6
+ ALTER TABLE users ADD COLUMN websocket_token CHARACTER VARYING(250) UNIQUE;
7
+ SQL
8
+ end
9
+
10
+ def down
11
+ execute <<-SQL
12
+ ALTER TABLE users DROP COLUMN websocket_token;
13
+ SQL
14
+ end
15
+ end
16
+
17
+ # eof
Original file line number Diff line number Diff line change @@ -1324,7 +1324,8 @@ CREATE TABLE users (
1324
1324
avatar_file_name character varying (255 ),
1325
1325
avatar_content_type character varying (255 ),
1326
1326
avatar_file_size integer ,
1327
- avatar_updated_at timestamp without time zone
1327
+ avatar_updated_at timestamp without time zone ,
1328
+ websocket_token character varying (250 )
1328
1329
);
1329
1330
1330
1331
@@ -1793,6 +1794,14 @@ ALTER TABLE ONLY users
1793
1794
ADD CONSTRAINT users_pkey PRIMARY KEY (user_id);
1794
1795
1795
1796
1797
+ --
1798
+ -- Name: users_websocket_token_key; Type: CONSTRAINT; Schema: cforum; Owner: -; Tablespace:
1799
+ --
1800
+
1801
+ ALTER TABLE ONLY users
1802
+ ADD CONSTRAINT users_websocket_token_key UNIQUE (websocket_token);
1803
+
1804
+
1796
1805
--
1797
1806
-- Name: votes_pkey; Type: CONSTRAINT; Schema: cforum; Owner: -; Tablespace:
1798
1807
--
@@ -2617,6 +2626,8 @@ INSERT INTO schema_migrations (version) VALUES ('54');
2617
2626
2618
2627
INSERT INTO schema_migrations (version) VALUES (' 55' );
2619
2628
2629
+ INSERT INTO schema_migrations (version) VALUES (' 56' );
2630
+
2620
2631
INSERT INTO schema_migrations (version) VALUES (' 6' );
2621
2632
2622
2633
INSERT INTO schema_migrations (version) VALUES (' 7' );
You can’t perform that action at this time.
0 commit comments