mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-09 23:58:06 -05:00
Compare commits
1262 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bb74c5abf | ||
|
|
a79057070c | ||
|
|
12fc5b76d8 | ||
|
|
ad5892391d | ||
|
|
df43a3560a | ||
|
|
9aa17eec07 | ||
|
|
45cc668683 | ||
|
|
19045a483d | ||
|
|
f618b88f91 | ||
|
|
81cb5b00f4 | ||
|
|
54fb582269 | ||
|
|
44f7325a91 | ||
|
|
4ab54943ad | ||
|
|
aedc9b7696 | ||
|
|
28248e3167 | ||
|
|
612e30258c | ||
|
|
76c888268b | ||
|
|
07f2712a22 | ||
|
|
75e8555035 | ||
|
|
2d53cf4424 | ||
|
|
e91b8ee0ba | ||
|
|
eced9b015b | ||
|
|
dbc3c4f08f | ||
|
|
0d56ae2705 | ||
|
|
c1e4031e3b | ||
|
|
964ae53e5b | ||
|
|
2e5b5fcd70 | ||
|
|
241e8077e3 | ||
|
|
55e726e4a7 | ||
|
|
f9d13f015a | ||
|
|
e704221842 | ||
|
|
2a6d608bd8 | ||
|
|
b2dc388556 | ||
|
|
214ce91bf7 | ||
|
|
a460d79b08 | ||
|
|
2f3a59640b | ||
|
|
1102600720 | ||
|
|
4e4e42e1ae | ||
|
|
20e299bce0 | ||
|
|
5be5220e5a | ||
|
|
fcb04f5302 | ||
|
|
45016829d6 | ||
|
|
337db5a3a2 | ||
|
|
a921c10e6a | ||
|
|
101e50f9df | ||
|
|
6064ca8b73 | ||
|
|
2dd322579f | ||
|
|
e72839f4bc | ||
|
|
45438fcfc4 | ||
|
|
f3329110ba | ||
|
|
369ba267ef | ||
|
|
a42033cb04 | ||
|
|
1aab449933 | ||
|
|
ee65cd60c9 | ||
|
|
c000b58c56 | ||
|
|
40e8812d75 | ||
|
|
cc6046b8cc | ||
|
|
6b1ead8654 | ||
|
|
518f6f39bf | ||
|
|
6edbeb82cd | ||
|
|
a8d0a8f63d | ||
|
|
62703943be | ||
|
|
e3a00b27d1 | ||
|
|
8266e85576 | ||
|
|
4372dd402b | ||
|
|
6e4b0b94bc | ||
|
|
bf74a506c8 | ||
|
|
e01fb8bb22 | ||
|
|
14785afe8d | ||
|
|
66a96ab9d6 | ||
|
|
76b87dc0e8 | ||
|
|
cb663e96a3 | ||
|
|
1192c76f62 | ||
|
|
ecd2187652 | ||
|
|
d1571627b7 | ||
|
|
52b24e41de | ||
|
|
5f62f28d6e | ||
|
|
c84169122f | ||
|
|
bafc23eae5 | ||
|
|
aa6cb411bc | ||
|
|
354df3bc65 | ||
|
|
6f140faf0d | ||
|
|
05bf574799 | ||
|
|
40f02ae69b | ||
|
|
3aedbf0a4d | ||
|
|
fa067b31c6 | ||
|
|
517010e2c5 | ||
|
|
4adc792422 | ||
|
|
0640b318ca | ||
|
|
95fad8b408 | ||
|
|
94adec3cee | ||
|
|
87b73540a4 | ||
|
|
25f908ad9c | ||
|
|
4656e96d9e | ||
|
|
389cd85d47 | ||
|
|
3b0bc08ec6 | ||
|
|
2eca92f950 | ||
|
|
acc45c5a44 | ||
|
|
e4dd1509c4 | ||
|
|
b8f644198d | ||
|
|
715192a770 | ||
|
|
31aceeb104 | ||
|
|
af8f7e9797 | ||
|
|
6c916488af | ||
|
|
246a50876a | ||
|
|
8866b8e5eb | ||
|
|
1c8e97c75a | ||
|
|
cd9ad848fb | ||
|
|
be15116426 | ||
|
|
9d90a559ce | ||
|
|
d98f38cf5f | ||
|
|
f99636da76 | ||
|
|
6260c29a86 | ||
|
|
45481df14a | ||
|
|
7eccd4e9c6 | ||
|
|
2cf18f99e0 | ||
|
|
bcbea08187 | ||
|
|
b20de505ab | ||
|
|
20bde34981 | ||
|
|
e9abba797a | ||
|
|
dac90eeb80 | ||
|
|
f220b992c3 | ||
|
|
2bb8e1c236 | ||
|
|
e44a8b2d43 | ||
|
|
268bd69164 | ||
|
|
d750709250 | ||
|
|
c9a2d0654e | ||
|
|
26723d9bbc | ||
|
|
75f9e76f65 | ||
|
|
962cea2039 | ||
|
|
64aad8b138 | ||
|
|
0d279415f3 | ||
|
|
fc45f916d6 | ||
|
|
3722aa6296 | ||
|
|
5664b19703 | ||
|
|
d870c0dced | ||
|
|
8ab7963e50 | ||
|
|
d545fe3e3f | ||
|
|
3e23371b01 | ||
|
|
6bda962547 | ||
|
|
f141bb57ec | ||
|
|
9001123b7e | ||
|
|
5919620b24 | ||
|
|
a45bbe1783 | ||
|
|
2514c69d81 | ||
|
|
8b53975652 | ||
|
|
bdd6081815 | ||
|
|
e55c9caa05 | ||
|
|
0f8695dd4b | ||
|
|
d9deeba582 | ||
|
|
d1948b79d3 | ||
|
|
371d657e35 | ||
|
|
82087ce211 | ||
|
|
463351922f | ||
|
|
3080e9e018 | ||
|
|
caf633854d | ||
|
|
f016e823cd | ||
|
|
9843cb27dc | ||
|
|
50bbb56576 | ||
|
|
135d898e0e | ||
|
|
b01ae718b3 | ||
|
|
8c9cc8d355 | ||
|
|
95689757c0 | ||
|
|
0720bc72c3 | ||
|
|
5f1c210511 | ||
|
|
16b3d6d67c | ||
|
|
7b3081760f | ||
|
|
5a3b7a1771 | ||
|
|
db011c0192 | ||
|
|
f39c6fd927 | ||
|
|
8b9fba73fd | ||
|
|
12298ef968 | ||
|
|
1b02534bef | ||
|
|
42b68d53a7 | ||
|
|
4f2e915833 | ||
|
|
f8c1ee0f90 | ||
|
|
2458334de6 | ||
|
|
451ba5362b | ||
|
|
31801fc9a0 | ||
|
|
ce0414271a | ||
|
|
701d4929d8 | ||
|
|
e61f4bae40 | ||
|
|
88e9a85d6a | ||
|
|
d6ffa8ef22 | ||
|
|
448106f458 | ||
|
|
a88f88eb4b | ||
|
|
2b10d517f6 | ||
|
|
4db1d819b0 | ||
|
|
840c2e7306 | ||
|
|
657507b705 | ||
|
|
975bb8490d | ||
|
|
6ceb649b10 | ||
|
|
bcb67ecde8 | ||
|
|
4184e23d71 | ||
|
|
a24f98f315 | ||
|
|
c74e2693a3 | ||
|
|
7a7a099573 | ||
|
|
215d034b86 | ||
|
|
3323197d68 | ||
|
|
1009096172 | ||
|
|
197ac56520 | ||
|
|
92b94bc84d | ||
|
|
71fc5b351a | ||
|
|
4e9860d268 | ||
|
|
ad8547dede | ||
|
|
079ed3b6f8 | ||
|
|
5e014ab607 | ||
|
|
0f6014b84d | ||
|
|
b5629ebf1d | ||
|
|
ee01bac8b0 | ||
|
|
3e1c9e343c | ||
|
|
399774af69 | ||
|
|
a62faa2c82 | ||
|
|
059dfc8cce | ||
|
|
cc6a582408 | ||
|
|
ce08d7abb8 | ||
|
|
83213569dd | ||
|
|
be2e17841e | ||
|
|
0591d92f53 | ||
|
|
244cc60d35 | ||
|
|
94c6d5f5cc | ||
|
|
0fe308e7a7 | ||
|
|
801cf00146 | ||
|
|
83002017ea | ||
|
|
0263b8dbfc | ||
|
|
4beeca46c4 | ||
|
|
7c4e8c8d17 | ||
|
|
36613b09d7 | ||
|
|
31774452e8 | ||
|
|
6eb412efae | ||
|
|
244c22a6a2 | ||
|
|
7d3d6fb3f0 | ||
|
|
ce071502ee | ||
|
|
32f63b2fb9 | ||
|
|
bacd9d244c | ||
|
|
a665aada25 | ||
|
|
0c5d78e31c | ||
|
|
60dc4be8c1 | ||
|
|
f7b6d78606 | ||
|
|
c605758800 | ||
|
|
2135ae5e5e | ||
|
|
a3d31778c2 | ||
|
|
d7f6855ad8 | ||
|
|
0a9e2c961f | ||
|
|
8387cc9474 | ||
|
|
70eb18d766 | ||
|
|
bf4641c8cf | ||
|
|
c76f0e59b7 | ||
|
|
fa2d333bde | ||
|
|
15a50dc8d7 | ||
|
|
a47928090a | ||
|
|
6fc6a28e3b | ||
|
|
6bc2db4567 | ||
|
|
5abdb65e56 | ||
|
|
25a3eeb30a | ||
|
|
33d5335f53 | ||
|
|
47077bf810 | ||
|
|
9caae50339 | ||
|
|
8a4d610c58 | ||
|
|
3d2a908f64 | ||
|
|
d2ea28b3db | ||
|
|
7a44233fb9 | ||
|
|
a9bb7d0318 | ||
|
|
ebe65b516b | ||
|
|
ebf79be163 | ||
|
|
88724e10ad | ||
|
|
30405943b5 | ||
|
|
9c0dccfec1 | ||
|
|
9fe7040db9 | ||
|
|
4c3838bb75 | ||
|
|
48aa20897f | ||
|
|
2a5f8b6688 | ||
|
|
8ee01fc10b | ||
|
|
d7985e7ddb | ||
|
|
ae8b0914a9 | ||
|
|
6720f93d2c | ||
|
|
13d4fd4088 | ||
|
|
bbd614a725 | ||
|
|
eb0540e028 | ||
|
|
08374f1d33 | ||
|
|
a5f8cd9d32 | ||
|
|
54e7a3b9d9 | ||
|
|
e761a8df2b | ||
|
|
65d8e94ed9 | ||
|
|
83b88353b5 | ||
|
|
39227bd494 | ||
|
|
e841c4c5ef | ||
|
|
e90ba2fbcb | ||
|
|
e6b5f5f31a | ||
|
|
245b1f9de0 | ||
|
|
e05523f767 | ||
|
|
2c8727ad42 | ||
|
|
b1508e93e1 | ||
|
|
5b57aa0b85 | ||
|
|
768656deb9 | ||
|
|
fe10a5b17a | ||
|
|
22784cb55a | ||
|
|
656720583f | ||
|
|
a20cca6873 | ||
|
|
8d78dc072f | ||
|
|
b2a2e85412 | ||
|
|
c2c74b0a39 | ||
|
|
92bb772d36 | ||
|
|
783234c72a | ||
|
|
2671f19cb1 | ||
|
|
72ea8392a8 | ||
|
|
bb44d422d6 | ||
|
|
5d304ae63a | ||
|
|
0c991af985 | ||
|
|
ac702843dd | ||
|
|
4015488b90 | ||
|
|
cccc137714 | ||
|
|
3fa0afad67 | ||
|
|
29142418ba | ||
|
|
c3b54dc0c2 | ||
|
|
a0232cf763 | ||
|
|
57980ba82a | ||
|
|
bcdd54cc5e | ||
|
|
83d5d3142d | ||
|
|
cbbe932ee2 | ||
|
|
593ae41f9d | ||
|
|
e9770fd434 | ||
|
|
53f6785e11 | ||
|
|
1b48fd0abe | ||
|
|
b835059baf | ||
|
|
f7359d6d96 | ||
|
|
4924dd68ae | ||
|
|
02ed166f51 | ||
|
|
9a11586a72 | ||
|
|
b5a5bae09c | ||
|
|
e757543323 | ||
|
|
7b000390a0 | ||
|
|
3f3ec236bb | ||
|
|
22dd3b489d | ||
|
|
0d45142845 | ||
|
|
62d6b5afb7 | ||
|
|
934fe45cfe | ||
|
|
675ae4d802 | ||
|
|
48251f236f | ||
|
|
8e6e70eaa7 | ||
|
|
4925ffda31 | ||
|
|
f89921e153 | ||
|
|
863b811167 | ||
|
|
d1f8884ee6 | ||
|
|
9caf07dd4f | ||
|
|
2044fffa25 | ||
|
|
2e442d81f7 | ||
|
|
28f0e3281a | ||
|
|
6a0d881554 | ||
|
|
4a9eee5a1c | ||
|
|
a4d3b9f14a | ||
|
|
1beac93961 | ||
|
|
8286325fd0 | ||
|
|
228f24c491 | ||
|
|
cff78eec23 | ||
|
|
20d786d7ca | ||
|
|
0c1b1a896f | ||
|
|
db8e247aa5 | ||
|
|
e01fdba557 | ||
|
|
0a1e55f11c | ||
|
|
85bcbdf18b | ||
|
|
a45c4c0ac4 | ||
|
|
d293e00ef5 | ||
|
|
201a4f92c2 | ||
|
|
71f90c0d6e | ||
|
|
26e22d8e95 | ||
|
|
9805728964 | ||
|
|
f64022a57b | ||
|
|
e79201aef8 | ||
|
|
a2498074f1 | ||
|
|
536279b05b | ||
|
|
031351224a | ||
|
|
74ab3e9a05 | ||
|
|
1bc9ebd7de | ||
|
|
81869de9c5 | ||
|
|
f6301c08f6 | ||
|
|
d66d9297fb | ||
|
|
78bbf6dcc4 | ||
|
|
1ff64fbbd3 | ||
|
|
3226ab16c1 | ||
|
|
13285d7ef3 | ||
|
|
7346ce709a | ||
|
|
8ac32f14b1 | ||
|
|
91ef42dc0a | ||
|
|
1ddca80cee | ||
|
|
896521be73 | ||
|
|
6e419ce821 | ||
|
|
93df02f601 | ||
|
|
fdd9337b64 | ||
|
|
2040b021e1 | ||
|
|
d122faf410 | ||
|
|
eaa4713e22 | ||
|
|
0c1a14e8f2 | ||
|
|
357ce9c3b5 | ||
|
|
830d3e86ee | ||
|
|
209b97d86b | ||
|
|
4da955d9cd | ||
|
|
bff701758a | ||
|
|
90acc6fc23 | ||
|
|
eba2527b8e | ||
|
|
48220f087b | ||
|
|
26b17abb01 | ||
|
|
22468f3756 | ||
|
|
9696d83e7d | ||
|
|
940ca4f2b8 | ||
|
|
f38250245f | ||
|
|
4c7c27f73e | ||
|
|
7a235849cf | ||
|
|
846ba80480 | ||
|
|
93d98b6450 | ||
|
|
7d10019d2a | ||
|
|
274f8f2f87 | ||
|
|
3360b10c2f | ||
|
|
6f9561e64f | ||
|
|
016b216d95 | ||
|
|
164134c78a | ||
|
|
4a4b5ba196 | ||
|
|
c87d8fda82 | ||
|
|
48af3e8249 | ||
|
|
57d150e535 | ||
|
|
d9f97fc9a4 | ||
|
|
9cdf7860d5 | ||
|
|
0f11c0f6b3 | ||
|
|
9914ff32ec | ||
|
|
728bf0c956 | ||
|
|
c520e93733 | ||
|
|
b397d33246 | ||
|
|
aa25e2080e | ||
|
|
2b3799e6ce | ||
|
|
2af3a83ef4 | ||
|
|
c3c2438c9c | ||
|
|
69bee06cee | ||
|
|
c70eb0a5a8 | ||
|
|
db901399f2 | ||
|
|
d0e5a1d252 | ||
|
|
ccda4692b4 | ||
|
|
e6563bc4cb | ||
|
|
1c2328bb90 | ||
|
|
9ec126bd8b | ||
|
|
b3cc3db49e | ||
|
|
5b1182460c | ||
|
|
76f76249e7 | ||
|
|
353b14f473 | ||
|
|
ec07bdb315 | ||
|
|
9ece7da447 | ||
|
|
b214333760 | ||
|
|
3423043759 | ||
|
|
8c636ef08a | ||
|
|
a9b94f5eb9 | ||
|
|
c228227bc1 | ||
|
|
0c46373c20 | ||
|
|
648ed3b412 | ||
|
|
cecb3ee45b | ||
|
|
4585281da4 | ||
|
|
014859ecff | ||
|
|
1f36946f43 | ||
|
|
9efc601c73 | ||
|
|
dc7e7d66c9 | ||
|
|
18528650c3 | ||
|
|
a371f03c51 | ||
|
|
f173040222 | ||
|
|
b74235d4a1 | ||
|
|
4b8ea5d0f0 | ||
|
|
79e861b52b | ||
|
|
c4b4411513 | ||
|
|
7b33a8ef57 | ||
|
|
1dd315ce1d | ||
|
|
7c75ebe672 | ||
|
|
d9481ff9b8 | ||
|
|
f0c39e08ca | ||
|
|
d3fa53151a | ||
|
|
f2d7b8f740 | ||
|
|
beb8cc8e0b | ||
|
|
17d6a74909 | ||
|
|
aab7610808 | ||
|
|
8edee143e8 | ||
|
|
49cf804c62 | ||
|
|
8ab738307e | ||
|
|
9d9adc73cd | ||
|
|
91f93b38ee | ||
|
|
7bff3be869 | ||
|
|
475599d4ab | ||
|
|
7d81731d4f | ||
|
|
ffe9d6d406 | ||
|
|
cf7c9be6b4 | ||
|
|
3e80c9a80f | ||
|
|
c6cf035037 | ||
|
|
6008885152 | ||
|
|
0c7f8764c9 | ||
|
|
d1d8c2f03d | ||
|
|
b97b3e6e3b | ||
|
|
cc02d06c58 | ||
|
|
b91bbb1590 | ||
|
|
52b1ca2d80 | ||
|
|
4ec7dc0f27 | ||
|
|
0a4da78b22 | ||
|
|
aa3f64976f | ||
|
|
260fa1a2e2 | ||
|
|
a321282ccc | ||
|
|
6f91baf99c | ||
|
|
1a7f2195a2 | ||
|
|
e5797001a7 | ||
|
|
f0b937c538 | ||
|
|
9639bf8cc1 | ||
|
|
27e1588685 | ||
|
|
42fac75e8e | ||
|
|
37b7e9b850 | ||
|
|
48e26c5d0a | ||
|
|
1d77099861 | ||
|
|
924a989f37 | ||
|
|
6431445846 | ||
|
|
8d57a54b2d | ||
|
|
280d12b81c | ||
|
|
00a0b8e516 | ||
|
|
238ccb15b5 | ||
|
|
ace7b55a1a | ||
|
|
97ab41728e | ||
|
|
acd9f84802 | ||
|
|
a24ecc65f5 | ||
|
|
4e45a5fde4 | ||
|
|
9499736593 | ||
|
|
df8b48646b | ||
|
|
b4904a4ba2 | ||
|
|
2006f87b58 | ||
|
|
5d9f6d892f | ||
|
|
1ac4bdd090 | ||
|
|
302c4e43bd | ||
|
|
f5926f6514 | ||
|
|
330e0f7165 | ||
|
|
42376db763 | ||
|
|
1147badf7c | ||
|
|
7b000390ac | ||
|
|
dd5de829c9 | ||
|
|
2f7834245b | ||
|
|
78d2654fb4 | ||
|
|
934dbd1f5a | ||
|
|
23933d2fb0 | ||
|
|
76bbbb8ed5 | ||
|
|
8701a88c94 | ||
|
|
2024fca4df | ||
|
|
032eb145df | ||
|
|
0d941b7ba5 | ||
|
|
f71d843f93 | ||
|
|
7d825c93b6 | ||
|
|
19b1e2a6bc | ||
|
|
901919f25f | ||
|
|
15c38d918f | ||
|
|
508c3418f9 | ||
|
|
d98e98fe77 | ||
|
|
4a45eb9899 | ||
|
|
45fc964470 | ||
|
|
56fed052f8 | ||
|
|
a0cd4655ba | ||
|
|
d3f521925e | ||
|
|
8a8887ea82 | ||
|
|
d22ac4a4fb | ||
|
|
8426b12550 | ||
|
|
57bf362b55 | ||
|
|
18a8260535 | ||
|
|
9f32f421a5 | ||
|
|
df6a83b27b | ||
|
|
4477bab1aa | ||
|
|
54bb30a1a4 | ||
|
|
5ae6360e75 | ||
|
|
d6dc93ca3d | ||
|
|
005d514adf | ||
|
|
9568e28d66 | ||
|
|
4f2571a408 | ||
|
|
e33d285e4a | ||
|
|
619128cb9b | ||
|
|
9f37b6eff7 | ||
|
|
2380612b6e | ||
|
|
c334179c95 | ||
|
|
827d009b3c | ||
|
|
56edeec958 | ||
|
|
7df57d5081 | ||
|
|
2ccffc80b0 | ||
|
|
797a19352c | ||
|
|
7025f968c6 | ||
|
|
04e01f49a9 | ||
|
|
a3da40a701 | ||
|
|
40258bf100 | ||
|
|
d3baff221d | ||
|
|
f5e984c151 | ||
|
|
6ed6e09bf3 | ||
|
|
05ccdfbacd | ||
|
|
9bcc2d1c5f | ||
|
|
211159f2eb | ||
|
|
ab141a8779 | ||
|
|
e9c82472ff | ||
|
|
48ed2fd1aa | ||
|
|
0fa74d863d | ||
|
|
c744dcf07a | ||
|
|
eb091b867f | ||
|
|
fb3568308e | ||
|
|
93b8f01583 | ||
|
|
068da8045b | ||
|
|
b12658782f | ||
|
|
3e87489c5b | ||
|
|
8aa0e2655e | ||
|
|
155e23a73e | ||
|
|
359fba970e | ||
|
|
3a056f6d10 | ||
|
|
213aa51126 | ||
|
|
8588387fad | ||
|
|
8c6de852c6 | ||
|
|
52e35f69c5 | ||
|
|
d9939d1ea0 | ||
|
|
703a0e0240 | ||
|
|
48d8285344 | ||
|
|
710496b6a8 | ||
|
|
2f45755e6c | ||
|
|
021f2da1e4 | ||
|
|
bc6361ab9b | ||
|
|
eb640ed344 | ||
|
|
5c244d9e2b | ||
|
|
e538f02f30 | ||
|
|
4064641967 | ||
|
|
c72be1531c | ||
|
|
f0a168da5a | ||
|
|
4d89c709a5 | ||
|
|
737a55f9e1 | ||
|
|
fe5b7db6ab | ||
|
|
b23f5223dd | ||
|
|
aa675f7f66 | ||
|
|
181920886e | ||
|
|
4d8bec435d | ||
|
|
89dbbfd0fd | ||
|
|
0164f5862c | ||
|
|
e966ba72b1 | ||
|
|
464edd5e5f | ||
|
|
5ba8f36958 | ||
|
|
e2041d02e8 | ||
|
|
d49533bedc | ||
|
|
3dc15c03a7 | ||
|
|
954767d456 | ||
|
|
6c993beb22 | ||
|
|
cc9a4e3edc | ||
|
|
0d59781ea8 | ||
|
|
1aaf6345a4 | ||
|
|
15b99977a2 | ||
|
|
055f67e414 | ||
|
|
099aee5c5b | ||
|
|
65dc208ad7 | ||
|
|
e3244b2c31 | ||
|
|
aa49dd53b5 | ||
|
|
916c0fc60b | ||
|
|
4acb504324 | ||
|
|
3207c73d4b | ||
|
|
2510c949e5 | ||
|
|
29e257e8ba | ||
|
|
1a0192201b | ||
|
|
8db50f4377 | ||
|
|
42c1ad3c78 | ||
|
|
e641b4b7b9 | ||
|
|
fe49e625e8 | ||
|
|
31901bc862 | ||
|
|
b14995167b | ||
|
|
4c137c4806 | ||
|
|
e5c3462a62 | ||
|
|
7952f1336d | ||
|
|
55ef8004e6 | ||
|
|
4b41dab11b | ||
|
|
1f3638aaa5 | ||
|
|
db63df7a8f | ||
|
|
b89537936b | ||
|
|
ac4a89a511 | ||
|
|
741df732dc | ||
|
|
d701ed764f | ||
|
|
369a5011f8 | ||
|
|
35de859e28 | ||
|
|
280c247b2f | ||
|
|
a8769933d1 | ||
|
|
74679bf3bc | ||
|
|
26492b3c50 | ||
|
|
a29fee1644 | ||
|
|
eac6c743fd | ||
|
|
bc38b044a4 | ||
|
|
85d75702ed | ||
|
|
7ca70a47ce | ||
|
|
c22e7133b6 | ||
|
|
2f0002a449 | ||
|
|
15d3fc497c | ||
|
|
e5400bc709 | ||
|
|
7c309f9b91 | ||
|
|
79c6f47ad3 | ||
|
|
885597025a | ||
|
|
8743ce6cf8 | ||
|
|
70ab38839f | ||
|
|
9aa72db365 | ||
|
|
18b6064d74 | ||
|
|
868d3d82a0 | ||
|
|
1ab2d51308 | ||
|
|
d1d5996b6b | ||
|
|
ef28bf2814 | ||
|
|
4837bb0a4e | ||
|
|
b02cd547e2 | ||
|
|
8d5c2c4fd9 | ||
|
|
0a0b4e00ea | ||
|
|
e1b9dc860f | ||
|
|
5802a57c76 | ||
|
|
f038c36161 | ||
|
|
4bb457ff6d | ||
|
|
ac79f1e114 | ||
|
|
61ec44b76e | ||
|
|
5e12508b96 | ||
|
|
737ae3632a | ||
|
|
a6a1524146 | ||
|
|
2992b411a2 | ||
|
|
d2658c6e35 | ||
|
|
893a0222ef | ||
|
|
fbb7a21abc | ||
|
|
ee8c13435f | ||
|
|
c19f1f27ce | ||
|
|
f0992e4a96 | ||
|
|
baef67cee7 | ||
|
|
00dc3932c6 | ||
|
|
7acc7a6659 | ||
|
|
fea2b95c5f | ||
|
|
8461234483 | ||
|
|
af8d38e45b | ||
|
|
a2e0e9c187 | ||
|
|
90f1d4d37a | ||
|
|
51c621ef51 | ||
|
|
9177bd70cf | ||
|
|
252a57d9b3 | ||
|
|
394d69d958 | ||
|
|
65700b22ba | ||
|
|
8d48bcd594 | ||
|
|
6dd4444582 | ||
|
|
3f95ac8fec | ||
|
|
c9fb1ebbfe | ||
|
|
bf2b37a39c | ||
|
|
8d3e0fddd3 | ||
|
|
1118762ce7 | ||
|
|
7e5d0ac736 | ||
|
|
c2fb80d4d9 | ||
|
|
5eb9f18743 | ||
|
|
5bb479052c | ||
|
|
8523801459 | ||
|
|
620478cc5f | ||
|
|
710efe557d | ||
|
|
6c5323c574 | ||
|
|
c92ef26b94 | ||
|
|
d6972ab264 | ||
|
|
5dc0f8dab9 | ||
|
|
b223ddeb35 | ||
|
|
1094ba65aa | ||
|
|
8d9dd50e4a | ||
|
|
7946f681a9 | ||
|
|
b2a66732cf | ||
|
|
71861ab0bf | ||
|
|
bb05314c8f | ||
|
|
bebf0ecbbe | ||
|
|
5c5200b5d9 | ||
|
|
5badce5e8e | ||
|
|
d0a30d485d | ||
|
|
2c8e242000 | ||
|
|
5e12b158d1 | ||
|
|
607bf70674 | ||
|
|
bf30ddddc0 | ||
|
|
13c2d4e807 | ||
|
|
a9d90503e9 | ||
|
|
c4dfd465d1 | ||
|
|
0522b1eb46 | ||
|
|
cb89e4435c | ||
|
|
6fb466eb1e | ||
|
|
9e93b9d700 | ||
|
|
640dd97149 | ||
|
|
681094663b | ||
|
|
0e218d8a01 | ||
|
|
16005ebcfe | ||
|
|
ae00e0bb20 | ||
|
|
d3d9fba201 | ||
|
|
bb24d18869 | ||
|
|
06e0f8adca | ||
|
|
a9e87f067a | ||
|
|
840ecb63a2 | ||
|
|
e9bf72be6a | ||
|
|
3b882dadac | ||
|
|
3015ac458d | ||
|
|
4599b57798 | ||
|
|
cf53131ed6 | ||
|
|
04561542b1 | ||
|
|
4ba84eeb27 | ||
|
|
c54e9863a6 | ||
|
|
adc031b214 | ||
|
|
a76dfd6552 | ||
|
|
0efd9244bf | ||
|
|
1bbcc54026 | ||
|
|
c7cc91cb65 | ||
|
|
e54326c19c | ||
|
|
63ae9701b4 | ||
|
|
c47ab5e6cf | ||
|
|
9e083c9689 | ||
|
|
12b5439f84 | ||
|
|
c7a135d6ba | ||
|
|
8c3c6ac10f | ||
|
|
b5713a8ddf | ||
|
|
6f88df3453 | ||
|
|
910868785c | ||
|
|
13e1a8fd8c | ||
|
|
5dedd8c4cf | ||
|
|
09f433691a | ||
|
|
3902e0702c | ||
|
|
d67388ad98 | ||
|
|
2a5ae0200d | ||
|
|
13e07b4b61 | ||
|
|
e46a21be16 | ||
|
|
e3f794f369 | ||
|
|
8a7796aea9 | ||
|
|
05d8d81ff4 | ||
|
|
a93edc72fd | ||
|
|
b910f5eb83 | ||
|
|
2c2e366500 | ||
|
|
11060fb8da | ||
|
|
cfe0dc1ee1 | ||
|
|
2c0186e090 | ||
|
|
51263f995b | ||
|
|
f9ca733e68 | ||
|
|
9c221e2418 | ||
|
|
ef016b448e | ||
|
|
a5bab11321 | ||
|
|
dae49f836a | ||
|
|
c1864663aa | ||
|
|
e96c9c961b | ||
|
|
5e58b1abfa | ||
|
|
f91dbd1b8b | ||
|
|
f80ebea0e6 | ||
|
|
2bae9da287 | ||
|
|
d6c8aef15f | ||
|
|
f246f62b10 | ||
|
|
bdf9c25f3b | ||
|
|
9b49e89ebd | ||
|
|
8e5c098e3a | ||
|
|
547e18e24e | ||
|
|
5ee215bcae | ||
|
|
6445e07791 | ||
|
|
fa7714218e | ||
|
|
6405c96213 | ||
|
|
1d8890b773 | ||
|
|
fd565c7efb | ||
|
|
c411ebcad6 | ||
|
|
8b15184a25 | ||
|
|
ed109ac3d5 | ||
|
|
6f8a383ff6 | ||
|
|
ee69d41fc1 | ||
|
|
1ed93cacd8 | ||
|
|
7eeaac9db1 | ||
|
|
64b4905410 | ||
|
|
002b4c6c01 | ||
|
|
0f240ab68f | ||
|
|
d546665102 | ||
|
|
d3c53904c7 | ||
|
|
9f63850279 | ||
|
|
6b0d11ed7a | ||
|
|
258a29636b | ||
|
|
c811ea2edb | ||
|
|
dce67416c5 | ||
|
|
c043eca2b2 | ||
|
|
39ed332299 | ||
|
|
8482e485d1 | ||
|
|
952c162bee | ||
|
|
131013ac56 | ||
|
|
79a4b93993 | ||
|
|
9fe1561b56 | ||
|
|
a5158939de | ||
|
|
7029a5aaa8 | ||
|
|
73c406b481 | ||
|
|
432a172533 | ||
|
|
1581a34ee4 | ||
|
|
32b5299547 | ||
|
|
ce6e369ba8 | ||
|
|
8a8e8c6519 | ||
|
|
48f03d8cc4 | ||
|
|
13c99d8162 | ||
|
|
6e0c287391 | ||
|
|
439112adf3 | ||
|
|
17f6c76dc7 | ||
|
|
6003c69818 | ||
|
|
a6f3f8cb4a | ||
|
|
716d128e27 | ||
|
|
db88341402 | ||
|
|
cc21c87bb3 | ||
|
|
67dc138d94 | ||
|
|
a9095b86d4 | ||
|
|
86ac552287 | ||
|
|
e2e9e90d69 | ||
|
|
daad552e1b | ||
|
|
2f81a83232 | ||
|
|
6ba87ed339 | ||
|
|
c25312e78e | ||
|
|
6af18ed9e3 | ||
|
|
930bed7a10 | ||
|
|
4ad2ed8f12 | ||
|
|
13eebb6b76 | ||
|
|
7dce5baf6c | ||
|
|
6117a3b56d | ||
|
|
274daad005 | ||
|
|
316be42ed6 | ||
|
|
220c8ff089 | ||
|
|
af47bb5542 | ||
|
|
992ee86b41 | ||
|
|
02b1a9c4e0 | ||
|
|
7b5293906b | ||
|
|
8de94035f0 | ||
|
|
d8d9814ed4 | ||
|
|
4f77da5b87 | ||
|
|
2f4fab00d9 | ||
|
|
2beae8e143 | ||
|
|
70e9e92d23 | ||
|
|
a638c21e76 | ||
|
|
9b9ee8bd2d | ||
|
|
0b13f587ef | ||
|
|
0e384f6fb6 | ||
|
|
7f3dac8652 | ||
|
|
df43642cd5 | ||
|
|
8e4a700f81 | ||
|
|
871b9b06f8 | ||
|
|
df9712bbe4 | ||
|
|
6e95b66b54 | ||
|
|
c37552f552 | ||
|
|
5d43d5f3bc | ||
|
|
6207e03070 | ||
|
|
c3fa8fabcf | ||
|
|
fe015f5a54 | ||
|
|
de2a24b3d3 | ||
|
|
67d8dd1e94 | ||
|
|
42c3523632 | ||
|
|
6f75fc7a14 | ||
|
|
876644168b | ||
|
|
880146668b | ||
|
|
086b77ae6d | ||
|
|
039b75ba83 | ||
|
|
eb9db7ba3a | ||
|
|
e65c26e1e7 | ||
|
|
c38accd648 | ||
|
|
447b7030f8 | ||
|
|
3cd6e650ef | ||
|
|
8a4fd04436 | ||
|
|
66db52ce31 | ||
|
|
b64f165154 | ||
|
|
1d803dd23b | ||
|
|
f1d57d7791 | ||
|
|
da01235a20 | ||
|
|
57d7a75b65 | ||
|
|
2e8aecdac2 | ||
|
|
9938a5e933 | ||
|
|
9a5783ade3 | ||
|
|
50679e1d93 | ||
|
|
b6af1675d5 | ||
|
|
520dfe2eb4 | ||
|
|
8df6980c9e | ||
|
|
6f7cd1332b | ||
|
|
8c7f6bd2aa | ||
|
|
89629e68c9 | ||
|
|
f0738098f0 | ||
|
|
9abee354f7 | ||
|
|
382492ce40 | ||
|
|
d0cb629f81 | ||
|
|
a11f54151b | ||
|
|
a0b97f5b5d | ||
|
|
83c01142a7 | ||
|
|
47ba796c26 | ||
|
|
eeb6060d9d | ||
|
|
301539378e | ||
|
|
cb48c9c408 | ||
|
|
74f4442319 | ||
|
|
2bde395840 | ||
|
|
8b3b3d7955 | ||
|
|
2174e4675e | ||
|
|
40068c4cba | ||
|
|
37e05380d1 | ||
|
|
65d7d1ba55 | ||
|
|
dfcb342a8f | ||
|
|
88efa6545f | ||
|
|
cb1d6c4684 | ||
|
|
8df6a2f38b | ||
|
|
395b5c4237 | ||
|
|
08d8591dfd | ||
|
|
09db3c65ec | ||
|
|
82b60fce15 | ||
|
|
0e14ac3aa7 | ||
|
|
dd56dc7da6 | ||
|
|
9818038a72 | ||
|
|
6a783c9ec7 | ||
|
|
451be888cb | ||
|
|
72f5eae391 | ||
|
|
4ee2402cd7 | ||
|
|
d8ee3e49cb | ||
|
|
6a628724ea | ||
|
|
c5c360cdd9 | ||
|
|
d47c370916 | ||
|
|
2f6edfd0c5 | ||
|
|
fa36464268 | ||
|
|
b51c3c1911 | ||
|
|
d1a9f220a1 | ||
|
|
426560a4db | ||
|
|
6129215afe | ||
|
|
916e1d8da9 | ||
|
|
1e8a387f34 | ||
|
|
a2376d6ca1 | ||
|
|
f611b63069 | ||
|
|
fa1a864731 | ||
|
|
53504f7e28 | ||
|
|
c7099ac5b0 | ||
|
|
bec913fc07 | ||
|
|
b5da4e82d0 | ||
|
|
ceafc710ef | ||
|
|
2d3ca4dc31 | ||
|
|
18da4b1eff | ||
|
|
1e8e8516f0 | ||
|
|
a51036196a | ||
|
|
2fc25a8c68 | ||
|
|
c8fcbde2af | ||
|
|
a3fc587c24 | ||
|
|
3014bcbc45 | ||
|
|
4110ab3228 | ||
|
|
303145c8b7 | ||
|
|
7bab20e55e | ||
|
|
33873426ad | ||
|
|
3e8fce5081 | ||
|
|
d875c01bc2 | ||
|
|
feff27aaee | ||
|
|
1dd84a8244 | ||
|
|
2dee54bc86 | ||
|
|
23761aded2 | ||
|
|
e085526b6e | ||
|
|
38b347ac00 | ||
|
|
9e8371c293 | ||
|
|
da49ed23f9 | ||
|
|
873e57e97d | ||
|
|
11c8875479 | ||
|
|
1ad09f9cfc | ||
|
|
13a8ad81ee | ||
|
|
b4c06d1ded | ||
|
|
d63b6b7b9d | ||
|
|
1fbc165b98 | ||
|
|
9cafe0dff6 | ||
|
|
a841e6c4f0 | ||
|
|
24327c7310 | ||
|
|
0b096c961a | ||
|
|
0a27a0da3b | ||
|
|
f37b10ef87 | ||
|
|
081ea9e0ba | ||
|
|
f60892be23 | ||
|
|
5f32cd25fd | ||
|
|
38e868dc79 | ||
|
|
67613117aa | ||
|
|
61c497d173 | ||
|
|
571dead19b | ||
|
|
b0b18fb805 | ||
|
|
5c57d88505 | ||
|
|
a2bd5631da | ||
|
|
6466d5c517 | ||
|
|
f7fdde1ab0 | ||
|
|
947169e4f5 | ||
|
|
9cada8d2d4 | ||
|
|
314f731a66 | ||
|
|
b786c384d5 | ||
|
|
6027787930 | ||
|
|
a38f2f96b5 | ||
|
|
d019e1ed1a | ||
|
|
58b311a93f | ||
|
|
de57ef83fb | ||
|
|
145ce9e1de | ||
|
|
7adf95b945 | ||
|
|
71d8dd37bb | ||
|
|
da0c27393f | ||
|
|
f19e82021f | ||
|
|
3d0559bc4d | ||
|
|
739c187e81 | ||
|
|
937ed6291c | ||
|
|
aa456c9d07 | ||
|
|
5b49bd3450 | ||
|
|
da34c54093 | ||
|
|
90e55409e1 | ||
|
|
ce3ead6b5f | ||
|
|
d439bc409c | ||
|
|
8d7a72326a | ||
|
|
59cd0cc240 | ||
|
|
1eab594895 | ||
|
|
755219ccfc | ||
|
|
9044631f4c | ||
|
|
a05d001c41 | ||
|
|
4064155312 | ||
|
|
a8e1d42097 | ||
|
|
0df786c849 | ||
|
|
ccfe389be1 | ||
|
|
a79e0f6bca | ||
|
|
3640abc933 | ||
|
|
09ebe833b3 | ||
|
|
4a0bc7692a | ||
|
|
0d06ed6c79 | ||
|
|
47845e44a2 | ||
|
|
71eb6176c3 | ||
|
|
7e6dd5022b | ||
|
|
286eefa9b4 | ||
|
|
5e00be4af8 | ||
|
|
a89af190e2 | ||
|
|
dbddce6acd | ||
|
|
1a87fd6477 | ||
|
|
00af1481f8 | ||
|
|
aea82d0b03 | ||
|
|
3d9dea39b2 | ||
|
|
dc1b399a8b | ||
|
|
a5ad61c167 | ||
|
|
146a2e500e | ||
|
|
2c5126dc42 | ||
|
|
a05548110f | ||
|
|
4995d3c221 | ||
|
|
1987ffc171 | ||
|
|
16b29baa5b | ||
|
|
49403267cf | ||
|
|
4d7473634e | ||
|
|
13b50d63ca | ||
|
|
b8f1d0d0c6 | ||
|
|
60b6a80764 | ||
|
|
5f9838950a | ||
|
|
0ece5d5190 | ||
|
|
058eac640f | ||
|
|
cc8636cfed | ||
|
|
e18b822567 | ||
|
|
93bdee2640 | ||
|
|
e57b672e90 | ||
|
|
e9351b7c15 | ||
|
|
7c3e08d92d | ||
|
|
46c01d642b | ||
|
|
2aedb1bf79 | ||
|
|
9d87aa55bd | ||
|
|
791657f3ef | ||
|
|
8981c3ef9b | ||
|
|
7a9ae13baa | ||
|
|
eba91e6580 | ||
|
|
d5e0171cb4 | ||
|
|
61e87be580 | ||
|
|
e16278966f | ||
|
|
2ba8275dcc | ||
|
|
72a0d9e350 | ||
|
|
6d51e67fac | ||
|
|
7b66133861 | ||
|
|
49086d0294 | ||
|
|
1b1be514c8 | ||
|
|
9dbc60d36d | ||
|
|
3db4444da8 | ||
|
|
7a654cdd04 | ||
|
|
02c2ec69dd | ||
|
|
dd95f3f3f7 | ||
|
|
0cb74efd79 | ||
|
|
517bde86d2 | ||
|
|
2665afa36f | ||
|
|
0b84a0e7c6 | ||
|
|
db204f33e0 | ||
|
|
89ce9c922c | ||
|
|
9d0d15b814 | ||
|
|
b50fa74596 | ||
|
|
be236fa6dd | ||
|
|
01e029fd9b | ||
|
|
4652b3efa0 | ||
|
|
29da146c07 | ||
|
|
a00921f417 | ||
|
|
71c43926e0 | ||
|
|
380ab682c5 | ||
|
|
714176994b | ||
|
|
8ca34aa41e | ||
|
|
3adeba38f5 | ||
|
|
5b6f1e8f80 | ||
|
|
16ec143228 | ||
|
|
c67de7e91c | ||
|
|
3f03ec02ad | ||
|
|
4e7cd18a04 | ||
|
|
01f4a8f441 | ||
|
|
53893edec8 | ||
|
|
7d11427116 | ||
|
|
26e85c44e2 | ||
|
|
43282f738e | ||
|
|
c2718806a7 | ||
|
|
3e3a3ad102 | ||
|
|
65947b6696 | ||
|
|
0028dc6a4f | ||
|
|
f438209669 | ||
|
|
c85ecbb9ac | ||
|
|
b16899f7bf | ||
|
|
bd83483ba6 | ||
|
|
0514e60bc4 | ||
|
|
7afc096fa4 | ||
|
|
bb2ff3553b | ||
|
|
1390945e5c | ||
|
|
f36efc0cc9 | ||
|
|
3b598ec235 | ||
|
|
95ec62ea76 | ||
|
|
9a412c139f | ||
|
|
0582467032 | ||
|
|
221be6d6ef | ||
|
|
ed86361b92 | ||
|
|
e303de9756 | ||
|
|
268e486dbb | ||
|
|
989071144e | ||
|
|
25726becdd | ||
|
|
bf5bcd52cb | ||
|
|
e26ea51fe5 | ||
|
|
c840fc419f | ||
|
|
9d872709c0 | ||
|
|
27bcefcf54 | ||
|
|
4f1bf8f3f9 | ||
|
|
d49f0a1184 | ||
|
|
a7624c8f51 | ||
|
|
52a3768451 | ||
|
|
f5f7e97d8b | ||
|
|
13117f01be | ||
|
|
fe1fb1f7a2 | ||
|
|
c87809a0f5 | ||
|
|
9eb0768cb9 | ||
|
|
e445039716 | ||
|
|
69d28f9b0e | ||
|
|
5cb575bd48 | ||
|
|
88de877f8b | ||
|
|
5a363f5fcb | ||
|
|
04e47687b2 | ||
|
|
d5514bf916 | ||
|
|
93649e21d0 | ||
|
|
8bef8b87f1 | ||
|
|
fb530110c7 | ||
|
|
bb810cfb8f | ||
|
|
a8069be4c8 | ||
|
|
2296d14803 | ||
|
|
21583cbf95 | ||
|
|
4861436298 | ||
|
|
844d467ab9 | ||
|
|
520e2845ae | ||
|
|
aba19c1ca4 | ||
|
|
986f52df2b | ||
|
|
e20e446cf4 | ||
|
|
e947a9cbec | ||
|
|
fa06b33dd3 | ||
|
|
31971e69e6 | ||
|
|
fa16afd90a | ||
|
|
0d6493a9a5 | ||
|
|
5300bdabc8 | ||
|
|
93f59dd63a | ||
|
|
9281ac3958 | ||
|
|
52300c033d | ||
|
|
036715facc | ||
|
|
2351d0215a | ||
|
|
eaad61b2da | ||
|
|
c323065b57 | ||
|
|
989d7192fa | ||
|
|
acefa2f761 | ||
|
|
ae6a37f796 | ||
|
|
d75fd56f15 | ||
|
|
4216c34538 | ||
|
|
b24d178b21 | ||
|
|
fc5522a8ed | ||
|
|
041fcf9080 | ||
|
|
f45d874ed9 | ||
|
|
47d9f1b959 | ||
|
|
9464416c3e | ||
|
|
6b3b0c5e8c | ||
|
|
dff7891b97 | ||
|
|
07f0ee75ee | ||
|
|
a1d83d5d4e | ||
|
|
01bb721c33 |
91
.travis.yml
91
.travis.yml
@@ -1,20 +1,91 @@
|
||||
language: ruby
|
||||
script: "bundle exec rake test"
|
||||
|
||||
rvm:
|
||||
- 1.9.3
|
||||
- 2.0.0
|
||||
env:
|
||||
- DEVISE_ORM=mongoid
|
||||
- DEVISE_ORM=active_record
|
||||
- 2.1.10
|
||||
- 2.2.10
|
||||
- 2.3.8
|
||||
- 2.4.5
|
||||
- 2.5.3
|
||||
- 2.6.0
|
||||
- ruby-head
|
||||
|
||||
gemfile:
|
||||
- gemfiles/Gemfile.rails-3.2.x
|
||||
- Gemfile
|
||||
- gemfiles/Gemfile.rails-6.0-stable
|
||||
- gemfiles/Gemfile.rails-5.2-stable
|
||||
- gemfiles/Gemfile.rails-5.0-stable
|
||||
- gemfiles/Gemfile.rails-4.2-stable
|
||||
- gemfiles/Gemfile.rails-4.1-stable
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- rvm: 2.1.10
|
||||
gemfile: Gemfile
|
||||
- rvm: 2.1.10
|
||||
gemfile: gemfiles/Gemfile.rails-6.0-stable
|
||||
- rvm: 2.1.10
|
||||
gemfile: gemfiles/Gemfile.rails-5.2-stable
|
||||
- rvm: 2.1.10
|
||||
gemfile: gemfiles/Gemfile.rails-5.0-stable
|
||||
- rvm: 2.2.10
|
||||
gemfile: Gemfile
|
||||
- rvm: 2.2.10
|
||||
gemfile: gemfiles/Gemfile.rails-6.0-stable
|
||||
- rvm: 2.2.10
|
||||
gemfile: gemfiles/Gemfile.rails-5.2-stable
|
||||
- rvm: 2.3.8
|
||||
gemfile: gemfiles/Gemfile.rails-6.0-stable
|
||||
- rvm: 2.4.5
|
||||
gemfile: gemfiles/Gemfile.rails-4.1-stable
|
||||
- rvm: 2.4.5
|
||||
gemfile: gemfiles/Gemfile.rails-6.0-stable
|
||||
- rvm: 2.5.3
|
||||
gemfile: gemfiles/Gemfile.rails-4.1-stable
|
||||
- rvm: 2.6.0
|
||||
gemfile: gemfiles/Gemfile.rails-4.1-stable
|
||||
- rvm: 2.6.0
|
||||
gemfile: gemfiles/Gemfile.rails-4.2-stable
|
||||
- rvm: ruby-head
|
||||
gemfile: gemfiles/Gemfile.rails-4.1-stable
|
||||
- rvm: ruby-head
|
||||
gemfile: gemfiles/Gemfile.rails-4.2-stable
|
||||
- env: DEVISE_ORM=mongoid
|
||||
gemfile: Gemfile
|
||||
- env: DEVISE_ORM=mongoid
|
||||
gemfile: gemfiles/Gemfile.rails-5.0-stable
|
||||
- env: DEVISE_ORM=mongoid
|
||||
gemfile: gemfiles/Gemfile.rails-5.2-stable
|
||||
- env: DEVISE_ORM=mongoid
|
||||
gemfile: gemfiles/Gemfile.rails-6.0-stable
|
||||
allow_failures:
|
||||
- rvm: ruby-head
|
||||
- gemfile: gemfiles/Gemfile.rails-6.0-stable
|
||||
|
||||
services:
|
||||
- mongodb
|
||||
|
||||
sudo: false
|
||||
|
||||
cache: bundler
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- DEVISE_ORM=active_record
|
||||
- DEVISE_ORM=mongoid
|
||||
|
||||
before_install:
|
||||
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
||||
- gem install bundler -v '< 2'
|
||||
- "rm ${BUNDLE_GEMFILE}.lock"
|
||||
|
||||
before_script: "bundle update"
|
||||
|
||||
script: "bin/test"
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
campfire:
|
||||
slack:
|
||||
on_pull_requests: false
|
||||
on_success: change
|
||||
on_failure: always
|
||||
rooms:
|
||||
- secure: "TRiqvuM4i/QmRDWjUSNitE5/P91BOzDkNl53+bZjjtxcISCswZtmECWBR7n9\n3xwqCOU1o2lfohxZ32OHOj/Nj7o+90zWJfWxcv+if0hIXRiil62M5pg0lZUd\nyJ4M5VQ0lSWo5he1OUrXhSabPJeaK3B8yT/tdh+qO5yzR+vb/jc="
|
||||
secure: Q3M+kmude3FjisibEeeGe0wSMXgvwLH+vL7Zrx9//q4QtkfnrQ/BBMvY9KXxPEsNF+eys4YopYjTkJ8uRmeboUATW/oQ4Jrv3+u3zkIHK2sFn/Q2cQWpK5w+CbgEnHPjKYnUu34b09njXTgDlr/mqtbPqrKeZ1dLlpKXCB/q4GY=
|
||||
|
||||
1268
CHANGELOG.md
1268
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
22
CODE_OF_CONDUCT.md
Normal file
22
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Contributor Code of Conduct
|
||||
|
||||
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
||||
|
||||
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery
|
||||
* Personal attacks
|
||||
* Trolling or insulting/derogatory comments
|
||||
* Public or private harassment
|
||||
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
|
||||
* Other unethical or unprofessional conduct.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
|
||||
|
||||
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by sending an email to [conduct@plataformatec.com.br](conduct@plataformatec.com.br) or contacting one or more of the project maintainers.
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
|
||||
@@ -1,14 +1,79 @@
|
||||
### Please read before contributing
|
||||
# How to contribute to Devise
|
||||
|
||||
1) Do not post questions in the issues tracker. If you have any questions about Devise, search the [Wiki](https://github.com/plataformatec/devise/wiki) or use the [Mailing List](https://groups.google.com/group/plataformatec-devise) or [Stack Overflow](http://stackoverflow.com/questions/tagged/devise).
|
||||
Thanks for your interest on contributing to Devise! Here are a few general
|
||||
guidelines on contributing and reporting bugs to Devise that we ask you to
|
||||
take a look first. Notice that all of your interactions in the project are
|
||||
expected to follow our [Code of Conduct](CODE_OF_CONDUCT.md).
|
||||
|
||||
2) If you find a security bug, **DO NOT** submit an issue here. Please send an e-mail to [developers@plataformatec.com.br](mailto:developers@plataformatec.com.br) instead.
|
||||
## Reporting Issues
|
||||
|
||||
3) Do a small search on the issues tracker before submitting your issue to see if it was already reported / fixed.
|
||||
Before reporting a new issue, please be sure that the issue wasn't already
|
||||
reported or fixed by searching on GitHub through our [issues](https://github.com/plataformatec/devise/issues).
|
||||
|
||||
4) When reporting an issue, include Rails, Devise and Warden versions. If you are getting exceptions, please include the full backtrace.
|
||||
When creating a new issue, be sure to include a **title and clear description**,
|
||||
as much relevant information as possible, and either a test case example or
|
||||
even better a **sample Rails app that replicates the issue** - Devise has a lot
|
||||
of moving parts and it's functionality can be affected by third party gems, so
|
||||
we need as much context and details as possible to identify what might be broken
|
||||
for you. We have a [test case template](guides/bug_report_templates/integration_test.rb)
|
||||
that can be used to replicate issues with minimal setup.
|
||||
|
||||
That's it! The more information you give, the easier it becomes for us to track it down and fix it.
|
||||
Ideally, you should provide an application that reproduces the error or a test case to Devise's suite.
|
||||
Please do not attempt to translate Devise built in views. The views are meant
|
||||
to be a starting point for fresh apps and not production material - eventually
|
||||
all applications will require custom views where you can write your own copy and
|
||||
translate it if the application requires it . For historical references, please look into closed
|
||||
[Issues/Pull Requests](https://github.com/plataformatec/devise/issues?q=i18n) regarding
|
||||
internationalization.
|
||||
|
||||
Thanks!
|
||||
Avoid opening new issues to ask questions in our issues tracker. Please go through
|
||||
the project wiki, documentation and source code first, or try to ask your question
|
||||
on [Stack Overflow](http://stackoverflow.com/questions/tagged/devise).
|
||||
|
||||
**If you find a security bug, do not report it through GitHub. Please send an
|
||||
e-mail to [opensource@plataformatec.com.br](mailto:opensource@plataformatec.com.br)
|
||||
instead.**
|
||||
|
||||
## Sending Pull Requests
|
||||
|
||||
Before sending a new Pull Request, take a look on existing Pull Requests and Issues
|
||||
to see if the proposed change or fix has been discussed in the past, or if the
|
||||
change was already implemented but not yet released.
|
||||
|
||||
We expect new Pull Requests to include enough tests for new or changed behavior,
|
||||
and we aim to maintain everything as most backwards compatible as possible,
|
||||
reserving breaking changes to be ship in major releases when necessary - you
|
||||
can wrap the new code path with a setting toggle from the `Devise` module defined
|
||||
as `false` by default to require developers to opt-in for the new behavior.
|
||||
|
||||
If your Pull Request includes new or changed behavior, be sure that the changes
|
||||
are beneficial to a wide range of use cases or it's an application specific change
|
||||
that might not be so valuable to other applications. Some changes can be introduced
|
||||
as a new `devise-something` gem instead of belonging to the main codebase.
|
||||
|
||||
When adding new settings, you can take advantage of the [`Devise::Models.config`](https://github.com/plataformatec/devise/blob/245b1f9de0b3386b7913e14b60ea24f43b77feb0/lib/devise/models.rb#L13-L50) method to add class and instance level fallbacks
|
||||
to the new setting.
|
||||
|
||||
We also welcome Pull Requests that improve our existing documentation (both our
|
||||
`README.md` and the RDoc sections in the source code) or improve existing rough
|
||||
edges in our API that might be blocking existing integrations or 3rd party gems.
|
||||
|
||||
## Other ways to contribute
|
||||
|
||||
We welcome anyone that wants to contribute to Devise to triage and reply to
|
||||
open issues to help troubleshoot and fix existing bugs on Devise. Here is what
|
||||
you can do:
|
||||
|
||||
* Help ensure that existing issues follows the recommendations from the
|
||||
_[Reporting Issues](#reporting-issues)_ section, providing feedback to the issue's
|
||||
author on what might be missing.
|
||||
* Review and update the existing content of our [Wiki](https://github.com/plataformatec/devise/wiki)
|
||||
with up to date instructions and code samples - the wiki was grown with several
|
||||
different tutorials and references that we can't keep track of everything, so if
|
||||
there is a page that showcases an integration or customization that you are
|
||||
familiar with feel free to update it as necessary.
|
||||
* Review existing Pull Requests, and testing patches against real existing
|
||||
applications that use Devise.
|
||||
|
||||
Thanks again for your interest on contributing to the project!
|
||||
|
||||
:heart:
|
||||
|
||||
33
Gemfile
33
Gemfile
@@ -1,17 +1,27 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec
|
||||
|
||||
gem "rails", "~> 4.0.0"
|
||||
gem "omniauth", "~> 1.0.0"
|
||||
gem "omniauth-oauth2", "~> 1.0.0"
|
||||
gem "rails", "~> 5.2"
|
||||
gem "omniauth", "~> 1.3"
|
||||
gem "oauth2"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc"
|
||||
|
||||
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
|
||||
|
||||
gem "rails-controller-testing"
|
||||
|
||||
gem "responders", "~> 2.4"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", :require => false
|
||||
gem "mocha", "~> 0.13.1", :require => false
|
||||
gem "omniauth-openid"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
end
|
||||
|
||||
platforms :jruby do
|
||||
@@ -21,11 +31,10 @@ platforms :jruby do
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3"
|
||||
gem "sqlite3", "~> 1.3.6"
|
||||
end
|
||||
|
||||
platforms :mri_19, :mri_20 do
|
||||
group :mongoid do
|
||||
gem "mongoid", github: "mongoid/mongoid", branch: "master"
|
||||
end
|
||||
end
|
||||
# TODO:
|
||||
# group :mongoid do
|
||||
# gem "mongoid", "~> 4.0.0"
|
||||
# end
|
||||
|
||||
288
Gemfile.lock
288
Gemfile.lock
@@ -1,160 +1,204 @@
|
||||
GIT
|
||||
remote: git://github.com/mongoid/mongoid.git
|
||||
revision: 346a79a7d01aa194de80e649916239a18d38ce13
|
||||
branch: master
|
||||
remote: git://github.com/rails/activemodel-serializers-xml.git
|
||||
revision: dd9c0acf26aab111ebc647cd8deb99ebc6946531
|
||||
specs:
|
||||
mongoid (4.0.0)
|
||||
activemodel (~> 4.0.0)
|
||||
moped (~> 1.5)
|
||||
origin (~> 1.0)
|
||||
tzinfo (~> 0.3.22)
|
||||
activemodel-serializers-xml (1.0.1)
|
||||
activemodel (> 5.x)
|
||||
activesupport (> 5.x)
|
||||
builder (~> 3.1)
|
||||
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
devise (3.1.0)
|
||||
bcrypt-ruby (~> 3.0)
|
||||
devise (4.7.0)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 3.2.6, < 5)
|
||||
thread_safe (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (4.0.0)
|
||||
actionpack (= 4.0.0)
|
||||
mail (~> 2.5.3)
|
||||
actionpack (4.0.0)
|
||||
activesupport (= 4.0.0)
|
||||
builder (~> 3.1.0)
|
||||
erubis (~> 2.7.0)
|
||||
rack (~> 1.5.2)
|
||||
rack-test (~> 0.6.2)
|
||||
activemodel (4.0.0)
|
||||
activesupport (= 4.0.0)
|
||||
builder (~> 3.1.0)
|
||||
activerecord (4.0.0)
|
||||
activemodel (= 4.0.0)
|
||||
activerecord-deprecated_finders (~> 1.0.2)
|
||||
activesupport (= 4.0.0)
|
||||
arel (~> 4.0.0)
|
||||
activerecord-deprecated_finders (1.0.3)
|
||||
activesupport (4.0.0)
|
||||
i18n (~> 0.6, >= 0.6.4)
|
||||
minitest (~> 4.2)
|
||||
multi_json (~> 1.3)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo (~> 0.3.37)
|
||||
arel (4.0.0)
|
||||
atomic (1.1.12)
|
||||
bcrypt-ruby (3.1.1)
|
||||
builder (3.1.4)
|
||||
erubis (2.7.0)
|
||||
faraday (0.8.8)
|
||||
multipart-post (~> 1.2.0)
|
||||
hashie (1.2.0)
|
||||
hike (1.2.3)
|
||||
httpauth (0.2.0)
|
||||
i18n (0.6.5)
|
||||
json (1.8.0)
|
||||
jwt (0.1.8)
|
||||
multi_json (>= 1.5)
|
||||
mail (2.5.4)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
metaclass (0.0.1)
|
||||
mime-types (1.23)
|
||||
minitest (4.7.5)
|
||||
mocha (0.13.3)
|
||||
actioncable (5.2.0)
|
||||
actionpack (= 5.2.0)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailer (5.2.0)
|
||||
actionpack (= 5.2.0)
|
||||
actionview (= 5.2.0)
|
||||
activejob (= 5.2.0)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.2.0)
|
||||
actionview (= 5.2.0)
|
||||
activesupport (= 5.2.0)
|
||||
rack (~> 2.0)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.2.0)
|
||||
activesupport (= 5.2.0)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (5.2.0)
|
||||
activesupport (= 5.2.0)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.2.0)
|
||||
activesupport (= 5.2.0)
|
||||
activerecord (5.2.0)
|
||||
activemodel (= 5.2.0)
|
||||
activesupport (= 5.2.0)
|
||||
arel (>= 9.0)
|
||||
activestorage (5.2.0)
|
||||
actionpack (= 5.2.0)
|
||||
activerecord (= 5.2.0)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (5.2.0)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (9.0.0)
|
||||
bcrypt (3.1.13)
|
||||
builder (3.2.3)
|
||||
concurrent-ruby (1.0.5)
|
||||
crass (1.0.4)
|
||||
erubi (1.7.1)
|
||||
faraday (0.11.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.4.1)
|
||||
activesupport (>= 4.2.0)
|
||||
hashie (3.5.7)
|
||||
i18n (1.0.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jwt (1.5.6)
|
||||
loofah (2.2.2)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.0)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.2)
|
||||
mimemagic (~> 0.3.2)
|
||||
metaclass (0.0.4)
|
||||
method_source (0.9.0)
|
||||
mimemagic (0.3.2)
|
||||
mini_mime (1.0.0)
|
||||
mini_portile2 (2.3.0)
|
||||
minitest (5.11.3)
|
||||
mocha (1.2.1)
|
||||
metaclass (~> 0.0.1)
|
||||
moped (1.5.1)
|
||||
multi_json (1.7.9)
|
||||
multipart-post (1.2.0)
|
||||
nokogiri (1.5.9)
|
||||
oauth2 (0.8.1)
|
||||
faraday (~> 0.8)
|
||||
httpauth (~> 0.1)
|
||||
jwt (~> 0.1.4)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.2)
|
||||
omniauth (1.0.3)
|
||||
hashie (~> 1.2)
|
||||
rack
|
||||
omniauth-facebook (1.4.0)
|
||||
omniauth-oauth2 (~> 1.0.2)
|
||||
omniauth-oauth2 (1.0.3)
|
||||
oauth2 (~> 0.8.0)
|
||||
omniauth (~> 1.0)
|
||||
multi_json (1.12.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.0.0)
|
||||
nio4r (2.3.0)
|
||||
nokogiri (1.8.2)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
oauth2 (1.3.1)
|
||||
faraday (>= 0.8, < 0.12)
|
||||
jwt (~> 1.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.8.1)
|
||||
hashie (>= 3.4.6, < 3.6.0)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (4.0.0)
|
||||
omniauth-oauth2 (~> 1.2)
|
||||
omniauth-oauth2 (1.4.0)
|
||||
oauth2 (~> 1.0)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
origin (1.1.0)
|
||||
orm_adapter (0.4.0)
|
||||
polyglot (0.3.3)
|
||||
rack (1.5.2)
|
||||
orm_adapter (0.5.0)
|
||||
rack (2.0.4)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
rails (4.0.0)
|
||||
actionmailer (= 4.0.0)
|
||||
actionpack (= 4.0.0)
|
||||
activerecord (= 4.0.0)
|
||||
activesupport (= 4.0.0)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.0.0)
|
||||
sprockets-rails (~> 2.0.0)
|
||||
railties (4.0.0)
|
||||
actionpack (= 4.0.0)
|
||||
activesupport (= 4.0.0)
|
||||
rack-test (1.0.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.2.0)
|
||||
actioncable (= 5.2.0)
|
||||
actionmailer (= 5.2.0)
|
||||
actionpack (= 5.2.0)
|
||||
actionview (= 5.2.0)
|
||||
activejob (= 5.2.0)
|
||||
activemodel (= 5.2.0)
|
||||
activerecord (= 5.2.0)
|
||||
activestorage (= 5.2.0)
|
||||
activesupport (= 5.2.0)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.2.0)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-controller-testing (1.0.1)
|
||||
actionpack (~> 5.x)
|
||||
actionview (~> 5.x)
|
||||
activesupport (~> 5.x)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.0.4)
|
||||
loofah (~> 2.2, >= 2.2.2)
|
||||
railties (5.2.0)
|
||||
actionpack (= 5.2.0)
|
||||
activesupport (= 5.2.0)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (10.1.0)
|
||||
rdoc (4.0.1)
|
||||
json (~> 1.4)
|
||||
ruby-openid (2.2.3)
|
||||
sprockets (2.10.0)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
sprockets-rails (2.0.0)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (~> 2.8)
|
||||
sqlite3 (1.3.7)
|
||||
thor (0.18.1)
|
||||
thread_safe (0.1.2)
|
||||
atomic
|
||||
tilt (1.4.1)
|
||||
treetop (1.4.14)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.37)
|
||||
warden (1.2.3)
|
||||
rake (12.3.1)
|
||||
rdoc (5.1.0)
|
||||
responders (2.4.0)
|
||||
actionpack (>= 4.2.0, < 5.3)
|
||||
railties (>= 4.2.0, < 5.3)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (3.7.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
thor (0.20.0)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.8.1)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.7)
|
||||
rack (>= 1.0)
|
||||
webrat (0.7.3)
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
websocket-driver (0.7.0)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activemodel-serializers-xml!
|
||||
activerecord-jdbc-adapter
|
||||
activerecord-jdbcsqlite3-adapter
|
||||
devise!
|
||||
jruby-openssl
|
||||
mocha (~> 0.13.1)
|
||||
mongoid!
|
||||
omniauth (~> 1.0.0)
|
||||
mocha (~> 1.1)
|
||||
oauth2
|
||||
omniauth (~> 1.3)
|
||||
omniauth-facebook
|
||||
omniauth-oauth2 (~> 1.0.0)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
rails (~> 4.0.0)
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails (~> 5.2)
|
||||
rails-controller-testing
|
||||
rdoc
|
||||
sqlite3
|
||||
responders (~> 2.4)
|
||||
sqlite3 (~> 1.3.6)
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
|
||||
20
ISSUE_TEMPLATE.md
Normal file
20
ISSUE_TEMPLATE.md
Normal file
@@ -0,0 +1,20 @@
|
||||
## Pre-check
|
||||
|
||||
- Do not use the issues tracker for help or support, try Stack Overflow.
|
||||
- For bugs, do a quick search and make sure the bug has not yet been reported
|
||||
- If you found a security bug, do not report it through GitHub. Please send an e-mail to opensource@plataformatec.com.br instead.
|
||||
- Finally, be nice and have fun!
|
||||
|
||||
## Environment
|
||||
|
||||
- Ruby **[version]**
|
||||
- Rails **[version]**
|
||||
- Devise **[version]**
|
||||
|
||||
## Current behavior
|
||||
|
||||
Include code samples, errors, steps to reproduce the error and stack traces if appropriate.
|
||||
|
||||
Will be even more helpful if you provide a sample application or a test case that reproduces the error.
|
||||
|
||||
## Expected behavior
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright 2009-2013 Plataformatec. http://plataformatec.com.br
|
||||
Copyright 2009-2019 Plataformatec. http://plataformatec.com.br
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
503
README.md
503
README.md
@@ -2,8 +2,8 @@
|
||||
|
||||
By [Plataformatec](http://plataformatec.com.br/).
|
||||
|
||||
[](http://travis-ci.org/plataformatec/devise)
|
||||
[](https://codeclimate.com/github/plataformatec/devise)
|
||||
[](http://travis-ci.org/plataformatec/devise)
|
||||
[](https://codeclimate.com/github/plataformatec/devise)
|
||||
|
||||
This README is [also available in a friendly navigable format](http://devise.plataformatec.com.br/).
|
||||
|
||||
@@ -12,22 +12,60 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
|
||||
* Is Rack based;
|
||||
* Is a complete MVC solution based on Rails engines;
|
||||
* Allows you to have multiple models signed in at the same time;
|
||||
* Is based on a modularity concept: use just what you really need.
|
||||
* Is based on a modularity concept: use only what you really need.
|
||||
|
||||
It's composed of 10 modules:
|
||||
|
||||
* [Database Authenticatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): encrypts and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
|
||||
* [Omniauthable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds Omniauth (https://github.com/intridea/omniauth) support;
|
||||
* [Confirmable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
|
||||
* [Recoverable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
|
||||
* [Registerable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
|
||||
* [Rememberable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
|
||||
* [Trackable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
|
||||
* [Timeoutable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable): expires sessions that have no activity in a specified period of time.
|
||||
* [Validatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
|
||||
* [Lockable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
|
||||
* [Database Authenticatable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): hashes and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
|
||||
* [Omniauthable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
|
||||
* [Confirmable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
|
||||
* [Recoverable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
|
||||
* [Registerable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
|
||||
* [Rememberable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
|
||||
* [Trackable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
|
||||
* [Timeoutable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
|
||||
* [Validatable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
|
||||
* [Lockable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
<!-- TOC depthFrom:1 depthTo:6 withLinks:1 orderedList:0 -->
|
||||
|
||||
- [Information](#information)
|
||||
- [The Devise wiki](#the-devise-wiki)
|
||||
- [Bug reports](#bug-reports)
|
||||
- [StackOverflow and Mailing List](#stackoverflow-and-mailing-list)
|
||||
- [RDocs](#rdocs)
|
||||
- [Example applications](#example-applications)
|
||||
- [Extensions](#extensions)
|
||||
- [Contributing](#contributing)
|
||||
- [Starting with Rails?](#starting-with-rails)
|
||||
- [Getting started](#getting-started)
|
||||
- [Controller filters and helpers](#controller-filters-and-helpers)
|
||||
- [Configuring Models](#configuring-models)
|
||||
- [Strong Parameters](#strong-parameters)
|
||||
- [Configuring views](#configuring-views)
|
||||
- [Configuring controllers](#configuring-controllers)
|
||||
- [Configuring routes](#configuring-routes)
|
||||
- [I18n](#i18n)
|
||||
- [Test helpers](#test-helpers)
|
||||
- [Controller tests](#controller-tests)
|
||||
- [Integration tests](#integration-tests)
|
||||
- [OmniAuth](#omniauth)
|
||||
- [Configuring multiple models](#configuring-multiple-models)
|
||||
- [ActiveJob Integration](#activejob-integration)
|
||||
- [Password reset tokens and Rails logs](#password-reset-tokens-and-rails-logs)
|
||||
- [Other ORMs](#other-orms)
|
||||
- [Rails API mode](#rails-api-mode)
|
||||
- [Additional information](#additional-information)
|
||||
- [Heroku](#heroku)
|
||||
- [Warden](#warden)
|
||||
- [Contributors](#contributors)
|
||||
- [License](#license)
|
||||
|
||||
<!-- /TOC -->
|
||||
|
||||
|
||||
Devise is guaranteed to be thread-safe on YARV. Thread-safety support on JRuby is on progress.
|
||||
|
||||
## Information
|
||||
|
||||
@@ -35,7 +73,7 @@ Devise is guaranteed to be thread-safe on YARV. Thread-safety support on JRuby i
|
||||
|
||||
The Devise Wiki has lots of additional information about Devise including many "how-to" articles and answers to the most frequently asked questions. Please browse the Wiki after finishing this README:
|
||||
|
||||
https://wiki.github.com/plataformatec/devise
|
||||
https://github.com/plataformatec/devise/wiki
|
||||
|
||||
### Bug reports
|
||||
|
||||
@@ -43,11 +81,15 @@ If you discover a problem with Devise, we would like to know about it. However,
|
||||
|
||||
https://github.com/plataformatec/devise/wiki/Bug-reports
|
||||
|
||||
If you found a security bug, do *NOT* use the GitHub issue tracker. Send an email to the maintainers listed at the bottom of the README.
|
||||
If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to opensource@plataformatec.com.br.
|
||||
|
||||
### Mailing list
|
||||
### StackOverflow and Mailing List
|
||||
|
||||
If you have any questions, comments, or concerns, please use the Google Group instead of the GitHub issue tracker:
|
||||
If you have any questions, comments, or concerns, please use StackOverflow instead of the GitHub issue tracker:
|
||||
|
||||
http://stackoverflow.com/questions/tagged/devise
|
||||
|
||||
The deprecated mailing list can still be read on
|
||||
|
||||
https://groups.google.com/group/plataformatec-devise
|
||||
|
||||
@@ -77,51 +119,114 @@ We hope that you will consider contributing to Devise. Please read this short ov
|
||||
|
||||
https://github.com/plataformatec/devise/wiki/Contributing
|
||||
|
||||
You will usually want to write tests for your changes. To run the test suite, go into Devise's top-level directory and run "bundle install" and "rake". For the tests to pass, you will need to have a MongoDB server (version 2.0 or newer) running on your system.
|
||||
You will usually want to write tests for your changes. To run the test suite, go into Devise's top-level directory and run `bundle install` and `bin/test`.
|
||||
Devise works with multiple Ruby and Rails versions, and ActiveRecord and Mongoid ORMs, which means you can run the test suite with some modifiers: `DEVISE_ORM` and `BUNDLE_GEMFILE`.
|
||||
|
||||
### DEVISE_ORM
|
||||
Since Devise support both Mongoid and ActiveRecord, we rely on this variable to run specific code for each ORM.
|
||||
The default value of `DEVISE_ORM` is `active_record`. To run the tests for mongoid, you can pass `mongoid`:
|
||||
```
|
||||
DEVISE_ORM=mongoid bin/test
|
||||
|
||||
==> Devise.orm = :mongoid
|
||||
```
|
||||
When running the tests for Mongoid, you will need to have a MongoDB server (version 2.0 or newer) running on your system.
|
||||
|
||||
Please note that the command output will show the variable value being used.
|
||||
|
||||
### BUNDLE_GEMFILE
|
||||
We can use this variable to tell bundler what Gemfile it should use (instead of the one in the current directory).
|
||||
Inside the [gemfiles](https://github.com/plataformatec/devise/tree/master/gemfiles) directory, we have one for each version of Rails we support. When you send us a pull request, it may happen that the test suite breaks on Travis using some of them. If that's the case, you can simulate the same environment using the `BUNDLE_GEMFILE` variable.
|
||||
For example, if the tests broke using Ruby 2.4.2 and Rails 4.1, you can do the following:
|
||||
```bash
|
||||
rbenv shell 2.4.2 # or rvm use 2.4.2
|
||||
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
|
||||
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bin/test
|
||||
```
|
||||
|
||||
You can also combine both of them if the tests broke for Mongoid:
|
||||
```bash
|
||||
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
|
||||
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable DEVISE_ORM=mongoid bin/test
|
||||
```
|
||||
|
||||
### Running tests
|
||||
Devise uses [Mini Test](https://github.com/seattlerb/minitest) as test framework.
|
||||
|
||||
* Running all tests:
|
||||
```bash
|
||||
bin/test
|
||||
```
|
||||
|
||||
* Running tests for an specific file:
|
||||
```bash
|
||||
bin/test test/models/trackable_test.rb
|
||||
```
|
||||
|
||||
* Running a specific test given a regex:
|
||||
```bash
|
||||
bin/test test/models/trackable_test.rb:16
|
||||
```
|
||||
|
||||
## Starting with Rails?
|
||||
|
||||
If you are building your first Rails application, we recommend you to *not* use Devise. Devise requires a good understanding of the Rails Framework. In such cases, we advise you to start a simple authentication system from scratch, today we have two resources:
|
||||
If you are building your first Rails application, we recommend you *do not* use Devise. Devise requires a good understanding of the Rails Framework. In such cases, we advise you to start a simple authentication system from scratch. Today, we have three resources that should help you get started:
|
||||
|
||||
* Michael Hartl's online book: http://railstutorial.org/chapters/modeling-and-viewing-users-two#top
|
||||
* Michael Hartl's online book: https://www.railstutorial.org/book/modeling_users
|
||||
* Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-from-scratch
|
||||
* Codecademy's Ruby on Rails: Authentication and Authorization: https://www.codecademy.com/learn/rails-auth
|
||||
|
||||
Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :)
|
||||
Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :smiley:
|
||||
|
||||
## Getting started
|
||||
|
||||
Devise 3.0 works with Rails 3.2 onwards. You can add it to your Gemfile with:
|
||||
Devise 4.0 works with Rails 4.1 onwards. Add the following line to your Gemfile:
|
||||
|
||||
```ruby
|
||||
gem 'devise'
|
||||
```
|
||||
|
||||
Run the bundle command to install it.
|
||||
Then run `bundle install`
|
||||
|
||||
After you install Devise and add it to your Gemfile, you need to run the generator:
|
||||
Next, you need to run the generator:
|
||||
|
||||
```console
|
||||
rails generate devise:install
|
||||
$ rails generate devise:install
|
||||
```
|
||||
|
||||
The generator will install an initializer which describes ALL Devise's configuration options and you MUST take a look at it. When you are done, you are ready to add Devise to any of your models using the generator:
|
||||
At this point, a number of instructions will appear in the console. Among these instructions, you'll need to set up the default URL options for the Devise mailer in each environment. Here is a possible configuration for `config/environments/development.rb`:
|
||||
|
||||
```ruby
|
||||
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
||||
```
|
||||
|
||||
The generator will install an initializer which describes ALL of Devise's configuration options. It is *imperative* that you take a look at it. When you are done, you are ready to add Devise to any of your models using the generator.
|
||||
|
||||
|
||||
In the following command you will replace `MODEL` with the class name used for the application’s users (it’s frequently `User` but could also be `Admin`). This will create a model (if one does not exist) and configure it with the default Devise modules. The generator also configures your `config/routes.rb` file to point to the Devise controller.
|
||||
|
||||
```console
|
||||
rails generate devise MODEL
|
||||
$ rails generate devise MODEL
|
||||
```
|
||||
|
||||
Replace MODEL by the class name used for the applications users, it's frequently `User` but could also be `Admin`. This will create a model (if one does not exist) and configure it with default Devise modules. Next, you'll usually run `rake db:migrate` as the generator will have created a migration file (if your ORM supports them). This generator also configures your config/routes.rb file to point to the Devise controller.
|
||||
Next, check the MODEL for any additional configuration options you might want to add, such as confirmable or lockable. If you add an option, be sure to inspect the migration file (created by the generator if your ORM supports them) and uncomment the appropriate section. For example, if you add the confirmable option in the model, you'll need to uncomment the Confirmable section in the migration.
|
||||
|
||||
Note that you should re-start your app here if you've already started it. Otherwise you'll run into strange errors like users being unable to login and the route helpers being undefined.
|
||||
Then run `rails db:migrate`
|
||||
|
||||
You should restart your application after changing Devise's configuration options (this includes stopping spring). Otherwise, you will run into strange errors, for example, users being unable to login and route helpers being undefined.
|
||||
|
||||
### Controller filters and helpers
|
||||
|
||||
Devise will create some helpers to use inside your controllers and views. To set up a controller with user authentication, just add this before_filter:
|
||||
Devise will create some helpers to use inside your controllers and views. To set up a controller with user authentication, just add this before_action (assuming your devise model is 'User'):
|
||||
|
||||
```ruby
|
||||
before_filter :authenticate_user!
|
||||
before_action :authenticate_user!
|
||||
```
|
||||
|
||||
For Rails 5, note that `protect_from_forgery` is no longer prepended to the `before_action` chain, so if you have set `authenticate_user` before `protect_from_forgery`, your request will result in "Can't verify CSRF token authenticity." To resolve this, either change the order in which you call them, or use `protect_from_forgery prepend: true`.
|
||||
|
||||
If your devise model is something other than User, replace "_user" with "_yourmodel". The same logic applies to the instructions below.
|
||||
|
||||
To verify if a user is signed in, use the following helper:
|
||||
|
||||
```ruby
|
||||
@@ -140,24 +245,18 @@ You can access the session for this scope:
|
||||
user_session
|
||||
```
|
||||
|
||||
After signing in a user, confirming the account or updating the password, Devise will look for a scoped root path to redirect. Example: For a :user resource, it will use `user_root_path` if it exists, otherwise default `root_path` will be used. This means that you need to set the root inside your routes:
|
||||
After signing in a user, confirming the account or updating the password, Devise will look for a scoped root path to redirect to. For instance, when using a `:user` resource, the `user_root_path` will be used if it exists; otherwise, the default `root_path` will be used. This means that you need to set the root inside your routes:
|
||||
|
||||
```ruby
|
||||
root to: "home#index"
|
||||
root to: 'home#index'
|
||||
```
|
||||
|
||||
You can also overwrite `after_sign_in_path_for` and `after_sign_out_path_for` to customize your redirect hooks.
|
||||
You can also override `after_sign_in_path_for` and `after_sign_out_path_for` to customize your redirect hooks.
|
||||
|
||||
Finally, you need to set up default url options for the mailer in each environment. Here is the configuration for "config/environments/development.rb":
|
||||
Notice that if your Devise model is called `Member` instead of `User`, for example, then the helpers available are:
|
||||
|
||||
```ruby
|
||||
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
||||
```
|
||||
|
||||
Notice that if your devise model is not called "user" but "member", then the helpers you should use are:
|
||||
|
||||
```ruby
|
||||
before_filter :authenticate_member!
|
||||
before_action :authenticate_member!
|
||||
|
||||
member_signed_in?
|
||||
|
||||
@@ -168,52 +267,88 @@ member_session
|
||||
|
||||
### Configuring Models
|
||||
|
||||
The devise method in your models also accepts some options to configure its modules. For example, you can choose the cost of the encryption algorithm with:
|
||||
The Devise method in your models also accepts some options to configure its modules. For example, you can choose the cost of the hashing algorithm with:
|
||||
|
||||
```ruby
|
||||
devise :database_authenticatable, :registerable, :confirmable, :recoverable, :stretches => 20
|
||||
devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 12
|
||||
```
|
||||
|
||||
Besides :stretches, you can define :pepper, :encryptor, :confirm_within, :remember_for, :timeout_in, :unlock_in and other values. For details, see the initializer file that was created when you invoked the "devise:install" generator described above.
|
||||
Besides `:stretches`, you can define `:pepper`, `:encryptor`, `:confirm_within`, `:remember_for`, `:timeout_in`, `:unlock_in` among other options. For more details, see the initializer file that was created when you invoked the "devise:install" generator described above. This file is usually located at `/config/initializers/devise.rb`.
|
||||
|
||||
### Strong Parameters
|
||||
|
||||

|
||||
|
||||
*For previous Devise versions see https://github.com/plataformatec/devise/tree/3-stable#strong-parameters*
|
||||
|
||||
When you customize your own views, you may end up adding new attributes to forms. Rails 4 moved the parameter sanitization from the model to the controller, causing Devise to handle this concern at the controller as well.
|
||||
|
||||
There are just three actions in Devise that allows any set of parameters to be passed down to the model, therefore requiring sanitization. Their names and the permited parameters by default are:
|
||||
There are just three actions in Devise that allow any set of parameters to be passed down to the model, therefore requiring sanitization. Their names and default permitted parameters are:
|
||||
|
||||
* `sign_in` (`Devise::SessionsController#new`) - Permits only the authentication keys (like `email`)
|
||||
* `sign_in` (`Devise::SessionsController#create`) - Permits only the authentication keys (like `email`)
|
||||
* `sign_up` (`Devise::RegistrationsController#create`) - Permits authentication keys plus `password` and `password_confirmation`
|
||||
* `account_update` (`Devise::RegistrationsController#update`) - Permits authentication keys plus `password`, `password_confirmation` and `current_password`
|
||||
|
||||
In case you want to permit additional parameters (the lazy way™) you can do with a simple before filter in your `ApplicationController`:
|
||||
In case you want to permit additional parameters (the lazy way™), you can do so using a simple before filter in your `ApplicationController`:
|
||||
|
||||
```ruby
|
||||
class ApplicationController < ActionController::Base
|
||||
before_filter :configure_permitted_parameters, if: :devise_controller?
|
||||
before_action :configure_permitted_parameters, if: :devise_controller?
|
||||
|
||||
protected
|
||||
|
||||
def configure_permitted_parameters
|
||||
devise_parameter_sanitizer.for(:sign_up) << :username
|
||||
devise_parameter_sanitizer.permit(:sign_up, keys: [:username])
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
To completely change Devise defaults or invoke custom behaviour, you can also pass a block:
|
||||
The above works for any additional fields where the parameters are simple scalar types. If you have nested attributes (say you're using `accepts_nested_attributes_for`), then you will need to tell devise about those nestings and types:
|
||||
|
||||
```ruby
|
||||
def configure_permitted_parameters
|
||||
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:username, :email) }
|
||||
class ApplicationController < ActionController::Base
|
||||
before_action :configure_permitted_parameters, if: :devise_controller?
|
||||
|
||||
protected
|
||||
|
||||
def configure_permitted_parameters
|
||||
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, address_attributes: [:country, :state, :city, :area, :postal_code]])
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
If you have multiple Devise models, you may want to set up different parameter sanitizer per model. In this case, we recommend inheriting from `Devise::ParameterSanitizer` and add your own logic:
|
||||
Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block:
|
||||
|
||||
To permit simple scalar values for username and email, use this
|
||||
|
||||
```ruby
|
||||
def configure_permitted_parameters
|
||||
devise_parameter_sanitizer.permit(:sign_in) do |user_params|
|
||||
user_params.permit(:username, :email)
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
If you have some checkboxes that express the roles a user may take on registration, the browser will send those selected checkboxes as an array. An array is not one of Strong Parameters' permitted scalars, so we need to configure Devise in the following way:
|
||||
|
||||
```ruby
|
||||
def configure_permitted_parameters
|
||||
devise_parameter_sanitizer.permit(:sign_up) do |user_params|
|
||||
user_params.permit({ roles: [] }, :email, :password, :password_confirmation)
|
||||
end
|
||||
end
|
||||
```
|
||||
For the list of permitted scalars, and how to declare permitted keys in nested hashes and arrays, see
|
||||
|
||||
https://github.com/rails/strong_parameters#nested-parameters
|
||||
|
||||
If you have multiple Devise models, you may want to set up a different parameter sanitizer per model. In this case, we recommend inheriting from `Devise::ParameterSanitizer` and adding your own logic:
|
||||
|
||||
```ruby
|
||||
class User::ParameterSanitizer < Devise::ParameterSanitizer
|
||||
def sign_in
|
||||
default_params.permit(:username, :email)
|
||||
def initialize(*)
|
||||
super
|
||||
permit(:sign_up, keys: [:username, :email])
|
||||
end
|
||||
end
|
||||
```
|
||||
@@ -243,63 +378,113 @@ We built Devise to help you quickly develop an application that uses authenticat
|
||||
Since Devise is an engine, all its views are packaged inside the gem. These views will help you get started, but after some time you may want to change them. If this is the case, you just need to invoke the following generator, and it will copy all views to your application:
|
||||
|
||||
```console
|
||||
rails generate devise:views
|
||||
$ rails generate devise:views
|
||||
```
|
||||
|
||||
If you have more than one Devise model in your application (such as "User" and "Admin"), you will notice that Devise uses the same views for all models. Fortunately, Devise offers an easy way to customize views. All you need to do is set "config.scoped_views = true" inside "config/initializers/devise.rb".
|
||||
If you have more than one Devise model in your application (such as `User` and `Admin`), you will notice that Devise uses the same views for all models. Fortunately, Devise offers an easy way to customize views. All you need to do is set `config.scoped_views = true` inside the `config/initializers/devise.rb` file.
|
||||
|
||||
After doing so, you will be able to have views based on the role like "users/sessions/new" and "admins/sessions/new". If no view is found within the scope, Devise will use the default view at "devise/sessions/new". You can also use the generator to generate scoped views:
|
||||
After doing so, you will be able to have views based on the role like `users/sessions/new` and `admins/sessions/new`. If no view is found within the scope, Devise will use the default view at `devise/sessions/new`. You can also use the generator to generate scoped views:
|
||||
|
||||
```console
|
||||
rails generate devise:views users
|
||||
$ rails generate devise:views users
|
||||
```
|
||||
|
||||
If you would like to generate only a few sets of views, like the ones for the `registerable` and `confirmable` module,
|
||||
you can pass a list of modules to the generator with the `-v` flag.
|
||||
|
||||
```console
|
||||
$ rails generate devise:views -v registrations confirmations
|
||||
```
|
||||
|
||||
### Configuring controllers
|
||||
|
||||
If the customization at the views level is not enough, you can customize each controller by following these steps:
|
||||
|
||||
1. Create your custom controller, for example a `Admins::SessionsController`:
|
||||
1. Create your custom controllers using the generator which requires a scope:
|
||||
|
||||
```ruby
|
||||
class Admins::SessionsController < Devise::SessionsController
|
||||
end
|
||||
```console
|
||||
$ rails generate devise:controllers [scope]
|
||||
```
|
||||
|
||||
Note that in the above example, the controller needs to be created in the `app/controller/admins/` directory.
|
||||
If you specify `users` as the scope, controllers will be created in `app/controllers/users/`.
|
||||
And the sessions controller will look like this:
|
||||
|
||||
```ruby
|
||||
class Users::SessionsController < Devise::SessionsController
|
||||
# GET /resource/sign_in
|
||||
# def new
|
||||
# super
|
||||
# end
|
||||
...
|
||||
end
|
||||
```
|
||||
(Use the -c flag to specify a controller, for example: `rails generate devise:controllers users -c=sessions`)
|
||||
|
||||
2. Tell the router to use this controller:
|
||||
|
||||
```ruby
|
||||
devise_for :admins, :controllers => { :sessions => "admins/sessions" }
|
||||
devise_for :users, controllers: { sessions: 'users/sessions' }
|
||||
```
|
||||
|
||||
3. And since we changed the controller, it won't use the `"devise/sessions"` views, so remember to copy `"devise/sessions"` to `"admin/sessions"`.
|
||||
3. Copy the views from `devise/sessions` to `users/sessions`. Since the controller was changed, it won't use the default views located in `devise/sessions`.
|
||||
|
||||
Remember that Devise uses flash messages to let users know if sign in was successful or failed. Devise expects your application to call `"flash[:notice]"` and `"flash[:alert]"` as appropriate. Do not print the entire flash hash, print specific keys or at least remove the `:timedout` key from the hash as Devise adds this key in some circumstances, this key is not meant for display.
|
||||
4. Finally, change or extend the desired controller actions.
|
||||
|
||||
You can completely override a controller action:
|
||||
|
||||
```ruby
|
||||
class Users::SessionsController < Devise::SessionsController
|
||||
def create
|
||||
# custom sign-in code
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
Or you can simply add new behaviour to it:
|
||||
|
||||
```ruby
|
||||
class Users::SessionsController < Devise::SessionsController
|
||||
def create
|
||||
super do |resource|
|
||||
BackgroundWorker.trigger(resource)
|
||||
end
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
This is useful for triggering background jobs or logging events during certain actions.
|
||||
|
||||
Remember that Devise uses flash messages to let users know if sign in was successful or unsuccessful. Devise expects your application to call `flash[:notice]` and `flash[:alert]` as appropriate. Do not print the entire flash hash, print only specific keys. In some circumstances, Devise adds a `:timedout` key to the flash hash, which is not meant for display. Remove this key from the hash if you intend to print the entire hash.
|
||||
|
||||
### Configuring routes
|
||||
|
||||
Devise also ships with default routes. If you need to customize them, you should probably be able to do it through the devise_for method. It accepts several options like :class_name, :path_prefix and so on, including the possibility to change path names for I18n:
|
||||
|
||||
```ruby
|
||||
devise_for :users, :path => "auth", :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification', :unlock => 'unblock', :registration => 'register', :sign_up => 'cmon_let_me_in' }
|
||||
devise_for :users, path: 'auth', path_names: { sign_in: 'login', sign_out: 'logout', password: 'secret', confirmation: 'verification', unlock: 'unblock', registration: 'register', sign_up: 'cmon_let_me_in' }
|
||||
```
|
||||
|
||||
Be sure to check `devise_for` documentation for details.
|
||||
Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/plataformatec/devise/master/ActionDispatch/Routing/Mapper%3Adevise_for) for details.
|
||||
|
||||
If you have the need for more deep customization, for instance to also allow "/sign_in" besides "/users/sign_in", all you need to do is to create your routes normally and wrap them in a `devise_scope` block in the router:
|
||||
If you have the need for more deep customization, for instance to also allow "/sign_in" besides "/users/sign_in", all you need to do is create your routes normally and wrap them in a `devise_scope` block in the router:
|
||||
|
||||
```ruby
|
||||
devise_scope :user do
|
||||
get "sign_in", :to => "devise/sessions#new"
|
||||
get 'sign_in', to: 'devise/sessions#new'
|
||||
end
|
||||
```
|
||||
|
||||
This way you tell devise to use the scope :user when "/sign_in" is accessed. Notice `devise_scope` is also aliased as `as` in your router.
|
||||
This way, you tell Devise to use the scope `:user` when "/sign_in" is accessed. Notice `devise_scope` is also aliased as `as` in your router.
|
||||
|
||||
Please note: You will still need to add `devise_for` in your routes in order to use helper methods such as `current_user`.
|
||||
|
||||
```ruby
|
||||
devise_for :users, skip: :all
|
||||
```
|
||||
|
||||
### I18n
|
||||
|
||||
Devise uses flash messages with I18n with the flash keys :notice and :alert. To customize your app, you can set up your locale file:
|
||||
Devise uses flash messages with I18n, in conjunction with the flash keys :notice and :alert. To customize your app, you can set up your locale file:
|
||||
|
||||
```yaml
|
||||
en:
|
||||
@@ -337,54 +522,115 @@ Take a look at our locale file to check all available messages. You may also be
|
||||
|
||||
https://github.com/plataformatec/devise/wiki/I18n
|
||||
|
||||
Caution: Devise Controllers inherit from ApplicationController. If your app uses multiple locales, you should be sure to set I18n.locale in ApplicationController.
|
||||
|
||||
### Test helpers
|
||||
|
||||
Devise includes some tests helpers for functional specs. In order to use them, you need to include Devise in your functional tests by adding the following to the bottom of your `test/test_helper.rb` file:
|
||||
Devise includes some test helpers for controller and integration tests.
|
||||
In order to use them, you need to include the respective module in your test
|
||||
cases/specs.
|
||||
|
||||
### Controller tests
|
||||
|
||||
Controller tests require that you include `Devise::Test::ControllerHelpers` on
|
||||
your test case or its parent `ActionController::TestCase` superclass.
|
||||
For Rails 5, include `Devise::Test::IntegrationHelpers` instead, since the superclass
|
||||
for controller tests has been changed to ActionDispatch::IntegrationTest
|
||||
(for more details, see the [Integration tests](#integration-tests) section).
|
||||
|
||||
```ruby
|
||||
class ActionController::TestCase
|
||||
include Devise::TestHelpers
|
||||
class PostsControllerTest < ActionController::TestCase
|
||||
include Devise::Test::ControllerHelpers
|
||||
end
|
||||
```
|
||||
|
||||
If you're using RSpec, you can put the following inside a file named `spec/support/devise.rb`:
|
||||
If you're using RSpec, you can put the following inside a file named
|
||||
`spec/support/devise.rb` or in your `spec/spec_helper.rb` (or
|
||||
`spec/rails_helper.rb` if you are using `rspec-rails`):
|
||||
|
||||
```ruby
|
||||
RSpec.configure do |config|
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
config.include Devise::Test::ControllerHelpers, type: :controller
|
||||
config.include Devise::Test::ControllerHelpers, type: :view
|
||||
end
|
||||
```
|
||||
|
||||
Now you are ready to use the `sign_in` and `sign_out` methods. Such methods have the same signature as in controllers:
|
||||
Just be sure that this inclusion is made *after* the `require 'rspec/rails'` directive.
|
||||
|
||||
Now you are ready to use the `sign_in` and `sign_out` methods on your controller
|
||||
tests:
|
||||
|
||||
```ruby
|
||||
sign_in :user, @user # sign_in(scope, resource)
|
||||
sign_in @user # sign_in(resource)
|
||||
|
||||
sign_out :user # sign_out(scope)
|
||||
sign_out @user # sign_out(resource)
|
||||
sign_in @user
|
||||
sign_in @user, scope: :admin
|
||||
```
|
||||
|
||||
There are two things that is important to keep in mind:
|
||||
|
||||
1. These helpers are not going to work for integration tests driven by Capybara or Webrat. They are meant to be used with functional tests only. Instead, fill in the form or explicitly set the user in session;
|
||||
|
||||
2. If you are testing Devise internal controllers or a controller that inherits from Devise's, you need to tell Devise which mapping should be used before a request. This is necessary because Devise gets this information from router, but since functional tests do not pass through the router, it needs to be told explicitly. For example, if you are testing the user scope, simply do:
|
||||
|
||||
```ruby
|
||||
@request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
get :new
|
||||
```
|
||||
|
||||
### Omniauth
|
||||
|
||||
Devise comes with Omniauth support out of the box to authenticate with other providers. To use it, just specify your omniauth configuration in `config/initializers/devise.rb`:
|
||||
If you are testing Devise internal controllers or a controller that inherits
|
||||
from Devise's, you need to tell Devise which mapping should be used before a
|
||||
request. This is necessary because Devise gets this information from the router,
|
||||
but since controller tests do not pass through the router, it needs to be stated
|
||||
explicitly. For example, if you are testing the user scope, simply use:
|
||||
|
||||
```ruby
|
||||
config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
||||
test 'GET new' do
|
||||
# Mimic the router behavior of setting the Devise scope through the env.
|
||||
@request.env['devise.mapping'] = Devise.mappings[:user]
|
||||
|
||||
# Use the sign_in helper to sign in a fixture `User` record.
|
||||
sign_in users(:alice)
|
||||
|
||||
get :new
|
||||
|
||||
# assert something
|
||||
end
|
||||
```
|
||||
|
||||
You can read more about Omniauth support in the wiki:
|
||||
### Integration tests
|
||||
|
||||
Integration test helpers are available by including the
|
||||
`Devise::Test::IntegrationHelpers` module.
|
||||
|
||||
```ruby
|
||||
class PostsTests < ActionDispatch::IntegrationTest
|
||||
include Devise::Test::IntegrationHelpers
|
||||
end
|
||||
```
|
||||
|
||||
Now you can use the following `sign_in` and `sign_out` methods in your integration
|
||||
tests:
|
||||
|
||||
```ruby
|
||||
sign_in users(:bob)
|
||||
sign_in users(:bob), scope: :admin
|
||||
|
||||
sign_out :user
|
||||
```
|
||||
|
||||
RSpec users can include the `IntegrationHelpers` module on their `:feature` specs.
|
||||
|
||||
```ruby
|
||||
RSpec.configure do |config|
|
||||
config.include Devise::Test::IntegrationHelpers, type: :feature
|
||||
end
|
||||
```
|
||||
|
||||
Unlike controller tests, integration tests do not need to supply the
|
||||
`devise.mapping` `env` value, as the mapping can be inferred by the routes that
|
||||
are executed in your tests.
|
||||
|
||||
You can read more about testing your Rails 3 - Rails 4 controllers with RSpec in the wiki:
|
||||
|
||||
* https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)
|
||||
|
||||
### OmniAuth
|
||||
|
||||
Devise comes with OmniAuth support out of the box to authenticate with other providers. To use it, simply specify your OmniAuth configuration in `config/initializers/devise.rb`:
|
||||
|
||||
```ruby
|
||||
config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
|
||||
```
|
||||
|
||||
You can read more about OmniAuth support in the wiki:
|
||||
|
||||
* https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
|
||||
|
||||
@@ -397,7 +643,7 @@ Devise allows you to set up as many Devise models as you want. If you want to ha
|
||||
create_table :admins do |t|
|
||||
t.string :email
|
||||
t.string :encrypted_password
|
||||
t.timestamps
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
# Inside your Admin model
|
||||
@@ -407,7 +653,7 @@ devise :database_authenticatable, :timeoutable
|
||||
devise_for :admins
|
||||
|
||||
# Inside your protected controller
|
||||
before_filter :authenticate_admin!
|
||||
before_action :authenticate_admin!
|
||||
|
||||
# Inside your controllers and views
|
||||
admin_signed_in?
|
||||
@@ -417,17 +663,54 @@ admin_session
|
||||
|
||||
Alternatively, you can simply run the Devise generator.
|
||||
|
||||
Keep in mind that those models will have completely different routes. They **do not** and **cannot** share the same controller for sign in, sign out and so on. In case you want to have different roles sharing the same actions, we recommend you to use a role-based approach, by either providing a role column or using [CanCan](https://github.com/ryanb/cancan).
|
||||
Keep in mind that those models will have completely different routes. They **do not** and **cannot** share the same controller for sign in, sign out and so on. In case you want to have different roles sharing the same actions, we recommend that you use a role-based approach, by either providing a role column or using a dedicated gem for authorization.
|
||||
|
||||
### ActiveJob Integration
|
||||
|
||||
If you are using Rails 4.2 and ActiveJob to deliver ActionMailer messages in the
|
||||
background through a queuing back-end, you can send Devise emails through your
|
||||
existing queue by overriding the `send_devise_notification` method in your model.
|
||||
|
||||
```ruby
|
||||
def send_devise_notification(notification, *args)
|
||||
devise_mailer.send(notification, self, *args).deliver_later
|
||||
end
|
||||
```
|
||||
|
||||
### Password reset tokens and Rails logs
|
||||
|
||||
If you enable the [Recoverable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable) module, note that a stolen password reset token could give an attacker access to your application. Devise takes effort to generate random, secure tokens, and stores only token digests in the database, never plaintext. However the default logging behavior in Rails can cause plaintext tokens to leak into log files:
|
||||
|
||||
1. Action Mailer logs the entire contents of all outgoing emails to the DEBUG level. Password reset tokens delivered to users in email will be leaked.
|
||||
2. Active Job logs all arguments to every enqueued job at the INFO level. If you configure Devise to use `deliver_later` to send password reset emails, password reset tokens will be leaked.
|
||||
|
||||
Rails sets the production logger level to DEBUG by default. Consider changing your production logger level to WARN if you wish to prevent tokens from being leaked into your logs. In `config/environments/production.rb`:
|
||||
|
||||
```ruby
|
||||
config.log_level = :warn
|
||||
```
|
||||
|
||||
|
||||
### Other ORMs
|
||||
|
||||
Devise supports ActiveRecord (default) and Mongoid. To choose other ORM, you just need to require it in the initializer file.
|
||||
Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simply require it in the initializer file.
|
||||
|
||||
### Rails API Mode
|
||||
|
||||
Rails 5+ has a built-in [API Mode](https://edgeguides.rubyonrails.org/api_app.html) which optimizes Rails for use as an API (only). One of the side effects is that it changes the order of the middleware stack, and this can cause problems for `Devise::Test::IntegrationHelpers`. This problem usually surfaces as an ```undefined method `[]=' for nil:NilClass``` error when using integration test helpers, such as `#sign_in`. The solution is simply to reorder the middlewares by adding the following to test.rb:
|
||||
|
||||
```ruby
|
||||
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Cookies
|
||||
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Session::CookieStore
|
||||
```
|
||||
|
||||
For a deeper understanding of this, review [this issue](https://github.com/plataformatec/devise/issues/4696).
|
||||
|
||||
## Additional information
|
||||
|
||||
### Heroku
|
||||
|
||||
Using devise on Heroku with Ruby on Rails 3.1 requires setting:
|
||||
Using Devise on Heroku with Ruby on Rails 3.2 requires setting:
|
||||
|
||||
```ruby
|
||||
config.assets.initialize_on_precompile = false
|
||||
@@ -445,10 +728,10 @@ https://github.com/hassox/warden
|
||||
|
||||
We have a long list of valued contributors. Check them all at:
|
||||
|
||||
https://github.com/plataformatec/devise/contributors
|
||||
https://github.com/plataformatec/devise/graphs/contributors
|
||||
|
||||
## License
|
||||
|
||||
MIT License. Copyright 2009-2013 Plataformatec. http://plataformatec.com.br
|
||||
MIT License. Copyright 2009-2019 Plataformatec. http://plataformatec.com.br
|
||||
|
||||
You are not granted rights or licenses to the trademarks of the Plataformatec, including without limitation the Devise name or logo.
|
||||
You are not granted rights or licenses to the trademarks of Plataformatec, including without limitation the Devise name or logo.
|
||||
|
||||
6
Rakefile
6
Rakefile
@@ -1,10 +1,12 @@
|
||||
# encoding: UTF-8
|
||||
require "bundler/gem_tasks"
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'bundler/gem_tasks'
|
||||
require 'rake/testtask'
|
||||
require 'rdoc/task'
|
||||
|
||||
desc 'Default: run tests for all ORMs.'
|
||||
task :default => :test
|
||||
task default: :test
|
||||
|
||||
desc 'Run Devise tests for all ORMs.'
|
||||
task :pre_commit do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Devise::ConfirmationsController < DeviseController
|
||||
# GET /resource/confirmation/new
|
||||
def new
|
||||
@@ -7,9 +9,10 @@ class Devise::ConfirmationsController < DeviseController
|
||||
# POST /resource/confirmation
|
||||
def create
|
||||
self.resource = resource_class.send_confirmation_instructions(resource_params)
|
||||
yield resource if block_given?
|
||||
|
||||
if successfully_sent?(resource)
|
||||
respond_with({}, :location => after_resending_confirmation_instructions_path_for(resource_name))
|
||||
respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name))
|
||||
else
|
||||
respond_with(resource)
|
||||
end
|
||||
@@ -18,17 +21,13 @@ class Devise::ConfirmationsController < DeviseController
|
||||
# GET /resource/confirmation?confirmation_token=abcdef
|
||||
def show
|
||||
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
|
||||
yield resource if block_given?
|
||||
|
||||
if resource.errors.empty?
|
||||
if Devise.allow_insecure_sign_in_after_confirmation
|
||||
set_flash_message(:notice, :confirmed_and_signed_in) if is_navigational_format?
|
||||
sign_in(resource_name, resource)
|
||||
else
|
||||
set_flash_message(:notice, :confirmed) if is_navigational_format?
|
||||
end
|
||||
set_flash_message!(:notice, :confirmed)
|
||||
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
|
||||
else
|
||||
respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new }
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,15 +35,19 @@ class Devise::ConfirmationsController < DeviseController
|
||||
|
||||
# The path used after resending confirmation instructions.
|
||||
def after_resending_confirmation_instructions_path_for(resource_name)
|
||||
new_session_path(resource_name) if is_navigational_format?
|
||||
is_navigational_format? ? new_session_path(resource_name) : '/'
|
||||
end
|
||||
|
||||
# The path used after confirmation.
|
||||
def after_confirmation_path_for(resource_name, resource)
|
||||
if Devise.allow_insecure_sign_in_after_confirmation
|
||||
after_sign_in_path_for(resource)
|
||||
if signed_in?(resource_name)
|
||||
signed_in_root_path(resource)
|
||||
else
|
||||
new_session_path(resource_name)
|
||||
end
|
||||
end
|
||||
|
||||
def translation_scope
|
||||
'devise.confirmations'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,30 +1,36 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Devise::OmniauthCallbacksController < DeviseController
|
||||
prepend_before_filter { request.env["devise.skip_timeout"] = true }
|
||||
prepend_before_action { request.env["devise.skip_timeout"] = true }
|
||||
|
||||
def passthru
|
||||
render :status => 404, :text => "Not found. Authentication passthru."
|
||||
render status: 404, plain: "Not found. Authentication passthru."
|
||||
end
|
||||
|
||||
def failure
|
||||
set_flash_message :alert, :failure, :kind => OmniAuth::Utils.camelize(failed_strategy.name), :reason => failure_message
|
||||
set_flash_message! :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name), reason: failure_message
|
||||
redirect_to after_omniauth_failure_path_for(resource_name)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def failed_strategy
|
||||
env["omniauth.error.strategy"]
|
||||
request.respond_to?(:get_header) ? request.get_header("omniauth.error.strategy") : request.env["omniauth.error.strategy"]
|
||||
end
|
||||
|
||||
def failure_message
|
||||
exception = env["omniauth.error"]
|
||||
exception = request.respond_to?(:get_header) ? request.get_header("omniauth.error") : request.env["omniauth.error"]
|
||||
error = exception.error_reason if exception.respond_to?(:error_reason)
|
||||
error ||= exception.error if exception.respond_to?(:error)
|
||||
error ||= env["omniauth.error.type"].to_s
|
||||
error ||= (request.respond_to?(:get_header) ? request.get_header("omniauth.error.type") : request.env["omniauth.error.type"]).to_s
|
||||
error.to_s.humanize if error
|
||||
end
|
||||
|
||||
def after_omniauth_failure_path_for(scope)
|
||||
new_session_path(scope)
|
||||
end
|
||||
|
||||
def translation_scope
|
||||
'devise.omniauth_callbacks'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Devise::PasswordsController < DeviseController
|
||||
prepend_before_filter :require_no_authentication
|
||||
prepend_before_action :require_no_authentication
|
||||
# Render the #edit only if coming from a reset password email link
|
||||
append_before_filter :assert_reset_token_passed, :only => :edit
|
||||
append_before_action :assert_reset_token_passed, only: :edit
|
||||
|
||||
# GET /resource/password/new
|
||||
def new
|
||||
@@ -11,9 +13,10 @@ class Devise::PasswordsController < DeviseController
|
||||
# POST /resource/password
|
||||
def create
|
||||
self.resource = resource_class.send_reset_password_instructions(resource_params)
|
||||
yield resource if block_given?
|
||||
|
||||
if successfully_sent?(resource)
|
||||
respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name))
|
||||
respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name))
|
||||
else
|
||||
respond_with(resource)
|
||||
end
|
||||
@@ -22,27 +25,35 @@ class Devise::PasswordsController < DeviseController
|
||||
# GET /resource/password/edit?reset_password_token=abcdef
|
||||
def edit
|
||||
self.resource = resource_class.new
|
||||
set_minimum_password_length
|
||||
resource.reset_password_token = params[:reset_password_token]
|
||||
end
|
||||
|
||||
# PUT /resource/password
|
||||
def update
|
||||
self.resource = resource_class.reset_password_by_token(resource_params)
|
||||
yield resource if block_given?
|
||||
|
||||
if resource.errors.empty?
|
||||
resource.unlock_access! if unlockable?(resource)
|
||||
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
|
||||
set_flash_message(:notice, flash_message) if is_navigational_format?
|
||||
sign_in(resource_name, resource)
|
||||
respond_with resource, :location => after_resetting_password_path_for(resource)
|
||||
if Devise.sign_in_after_reset_password
|
||||
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
|
||||
set_flash_message!(:notice, flash_message)
|
||||
resource.after_database_authentication
|
||||
sign_in(resource_name, resource)
|
||||
else
|
||||
set_flash_message!(:notice, :updated_not_active)
|
||||
end
|
||||
respond_with resource, location: after_resetting_password_path_for(resource)
|
||||
else
|
||||
set_minimum_password_length
|
||||
respond_with resource
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
def after_resetting_password_path_for(resource)
|
||||
after_sign_in_path_for(resource)
|
||||
Devise.sign_in_after_reset_password ? after_sign_in_path_for(resource) : new_session_path(resource_name)
|
||||
end
|
||||
|
||||
# The path used after sending reset password instructions
|
||||
@@ -65,4 +76,8 @@ class Devise::PasswordsController < DeviseController
|
||||
resource.respond_to?(:unlock_strategy_enabled?) &&
|
||||
resource.unlock_strategy_enabled?(:email)
|
||||
end
|
||||
|
||||
def translation_scope
|
||||
'devise.passwords'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,29 +1,36 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Devise::RegistrationsController < DeviseController
|
||||
prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ]
|
||||
prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]
|
||||
prepend_before_action :require_no_authentication, only: [:new, :create, :cancel]
|
||||
prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy]
|
||||
prepend_before_action :set_minimum_password_length, only: [:new, :edit]
|
||||
|
||||
# GET /resource/sign_up
|
||||
def new
|
||||
build_resource({})
|
||||
respond_with self.resource
|
||||
build_resource
|
||||
yield resource if block_given?
|
||||
respond_with resource
|
||||
end
|
||||
|
||||
# POST /resource
|
||||
def create
|
||||
build_resource(sign_up_params)
|
||||
|
||||
if resource.save
|
||||
resource.save
|
||||
yield resource if block_given?
|
||||
if resource.persisted?
|
||||
if resource.active_for_authentication?
|
||||
set_flash_message :notice, :signed_up if is_navigational_format?
|
||||
set_flash_message! :notice, :signed_up
|
||||
sign_up(resource_name, resource)
|
||||
respond_with resource, :location => after_sign_up_path_for(resource)
|
||||
respond_with resource, location: after_sign_up_path_for(resource)
|
||||
else
|
||||
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
|
||||
expire_session_data_after_sign_in!
|
||||
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
|
||||
set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}"
|
||||
expire_data_after_sign_in!
|
||||
respond_with resource, location: after_inactive_sign_up_path_for(resource)
|
||||
end
|
||||
else
|
||||
clean_up_passwords resource
|
||||
set_minimum_password_length
|
||||
respond_with resource
|
||||
end
|
||||
end
|
||||
@@ -40,16 +47,16 @@ class Devise::RegistrationsController < DeviseController
|
||||
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
|
||||
prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
|
||||
|
||||
if update_resource(resource, account_update_params)
|
||||
if is_navigational_format?
|
||||
flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?
|
||||
:update_needs_confirmation : :updated
|
||||
set_flash_message :notice, flash_key
|
||||
end
|
||||
sign_in resource_name, resource, :bypass => true
|
||||
respond_with resource, :location => after_update_path_for(resource)
|
||||
resource_updated = update_resource(resource, account_update_params)
|
||||
yield resource if block_given?
|
||||
if resource_updated
|
||||
set_flash_message_for_update(resource, prev_unconfirmed_email)
|
||||
bypass_sign_in resource, scope: resource_name if sign_in_after_change_password?
|
||||
|
||||
respond_with resource, location: after_update_path_for(resource)
|
||||
else
|
||||
clean_up_passwords resource
|
||||
set_minimum_password_length
|
||||
respond_with resource
|
||||
end
|
||||
end
|
||||
@@ -58,7 +65,8 @@ class Devise::RegistrationsController < DeviseController
|
||||
def destroy
|
||||
resource.destroy
|
||||
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
|
||||
set_flash_message :notice, :destroyed if is_navigational_format?
|
||||
set_flash_message! :notice, :destroyed
|
||||
yield resource if block_given?
|
||||
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
|
||||
end
|
||||
|
||||
@@ -68,7 +76,7 @@ class Devise::RegistrationsController < DeviseController
|
||||
# cancel oauth signing in/up in the middle of the process,
|
||||
# removing all OAuth session data.
|
||||
def cancel
|
||||
expire_session_data_after_sign_in!
|
||||
expire_data_after_sign_in!
|
||||
redirect_to new_registration_path(resource_name)
|
||||
end
|
||||
|
||||
@@ -88,8 +96,8 @@ class Devise::RegistrationsController < DeviseController
|
||||
|
||||
# Build a devise resource passing in the session. Useful to move
|
||||
# temporary session data to the newly created user.
|
||||
def build_resource(hash=nil)
|
||||
self.resource = resource_class.new_with_session(hash || {}, session)
|
||||
def build_resource(hash = {})
|
||||
self.resource = resource_class.new_with_session(hash, session)
|
||||
end
|
||||
|
||||
# Signs in a user on sign up. You can overwrite this method in your own
|
||||
@@ -101,24 +109,27 @@ class Devise::RegistrationsController < DeviseController
|
||||
# The path used after sign up. You need to overwrite this method
|
||||
# in your own RegistrationsController.
|
||||
def after_sign_up_path_for(resource)
|
||||
after_sign_in_path_for(resource)
|
||||
after_sign_in_path_for(resource) if is_navigational_format?
|
||||
end
|
||||
|
||||
# The path used after sign up for inactive accounts. You need to overwrite
|
||||
# this method in your own RegistrationsController.
|
||||
def after_inactive_sign_up_path_for(resource)
|
||||
respond_to?(:root_path) ? root_path : "/"
|
||||
scope = Devise::Mapping.find_scope!(resource)
|
||||
router_name = Devise.mappings[scope].router_name
|
||||
context = router_name ? send(router_name) : self
|
||||
context.respond_to?(:root_path) ? context.root_path : "/"
|
||||
end
|
||||
|
||||
# The default url to be used after updating a resource. You need to overwrite
|
||||
# this method in your own RegistrationsController.
|
||||
def after_update_path_for(resource)
|
||||
signed_in_root_path(resource)
|
||||
sign_in_after_change_password? ? signed_in_root_path(resource) : new_session_path(resource_name)
|
||||
end
|
||||
|
||||
# Authenticates the current scope and gets the current resource from the session.
|
||||
def authenticate_scope!
|
||||
send(:"authenticate_#{resource_name}!", :force => true)
|
||||
send(:"authenticate_#{resource_name}!", force: true)
|
||||
self.resource = send(:"current_#{resource_name}")
|
||||
end
|
||||
|
||||
@@ -129,4 +140,29 @@ class Devise::RegistrationsController < DeviseController
|
||||
def account_update_params
|
||||
devise_parameter_sanitizer.sanitize(:account_update)
|
||||
end
|
||||
|
||||
def translation_scope
|
||||
'devise.registrations'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_flash_message_for_update(resource, prev_unconfirmed_email)
|
||||
return unless is_flashing_format?
|
||||
|
||||
flash_key = if update_needs_confirmation?(resource, prev_unconfirmed_email)
|
||||
:update_needs_confirmation
|
||||
elsif sign_in_after_change_password?
|
||||
:updated
|
||||
else
|
||||
:updated_but_not_signed_in
|
||||
end
|
||||
set_flash_message :notice, flash_key
|
||||
end
|
||||
|
||||
def sign_in_after_change_password?
|
||||
return true if account_update_params[:password].blank?
|
||||
|
||||
Devise.sign_in_after_change_password
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,35 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Devise::SessionsController < DeviseController
|
||||
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
|
||||
prepend_before_filter :allow_params_authentication!, :only => :create
|
||||
prepend_before_filter { request.env["devise.skip_timeout"] = true }
|
||||
prepend_before_action :require_no_authentication, only: [:new, :create]
|
||||
prepend_before_action :allow_params_authentication!, only: :create
|
||||
prepend_before_action :verify_signed_out_user, only: :destroy
|
||||
prepend_before_action(only: [:create, :destroy]) { request.env["devise.skip_timeout"] = true }
|
||||
|
||||
# GET /resource/sign_in
|
||||
def new
|
||||
self.resource = resource_class.new(sign_in_params)
|
||||
clean_up_passwords(resource)
|
||||
yield resource if block_given?
|
||||
respond_with(resource, serialize_options(resource))
|
||||
end
|
||||
|
||||
# POST /resource/sign_in
|
||||
def create
|
||||
self.resource = warden.authenticate!(auth_options)
|
||||
set_flash_message(:notice, :signed_in) if is_navigational_format?
|
||||
set_flash_message!(:notice, :signed_in)
|
||||
sign_in(resource_name, resource)
|
||||
respond_with resource, :location => after_sign_in_path_for(resource)
|
||||
yield resource if block_given?
|
||||
respond_with resource, location: after_sign_in_path_for(resource)
|
||||
end
|
||||
|
||||
# DELETE /resource/sign_out
|
||||
def destroy
|
||||
redirect_path = after_sign_out_path_for(resource_name)
|
||||
signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
|
||||
set_flash_message :notice, :signed_out if signed_out && is_navigational_format?
|
||||
|
||||
# We actually need to hardcode this as Rails default responder doesn't
|
||||
# support returning empty response on GET request
|
||||
respond_to do |format|
|
||||
format.all { head :no_content }
|
||||
format.any(*navigational_formats) { redirect_to redirect_path }
|
||||
end
|
||||
set_flash_message! :notice, :signed_out if signed_out
|
||||
yield if block_given?
|
||||
respond_to_on_destroy
|
||||
end
|
||||
|
||||
protected
|
||||
@@ -42,10 +41,43 @@ class Devise::SessionsController < DeviseController
|
||||
methods = resource_class.authentication_keys.dup
|
||||
methods = methods.keys if methods.is_a?(Hash)
|
||||
methods << :password if resource.respond_to?(:password)
|
||||
{ :methods => methods, :only => [:password] }
|
||||
{ methods: methods, only: [:password] }
|
||||
end
|
||||
|
||||
def auth_options
|
||||
{ :scope => resource_name, :recall => "#{controller_path}#new" }
|
||||
{ scope: resource_name, recall: "#{controller_path}#new" }
|
||||
end
|
||||
|
||||
def translation_scope
|
||||
'devise.sessions'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Check if there is no signed in user before doing the sign out.
|
||||
#
|
||||
# If there is no signed in user, it will set the flash message and redirect
|
||||
# to the after_sign_out path.
|
||||
def verify_signed_out_user
|
||||
if all_signed_out?
|
||||
set_flash_message! :notice, :already_signed_out
|
||||
|
||||
respond_to_on_destroy
|
||||
end
|
||||
end
|
||||
|
||||
def all_signed_out?
|
||||
users = Devise.mappings.keys.map { |s| warden.user(scope: s, run_callbacks: false) }
|
||||
|
||||
users.all?(&:blank?)
|
||||
end
|
||||
|
||||
def respond_to_on_destroy
|
||||
# We actually need to hardcode this as Rails default responder doesn't
|
||||
# support returning empty response on GET request
|
||||
respond_to do |format|
|
||||
format.all { head :no_content }
|
||||
format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Devise::UnlocksController < DeviseController
|
||||
prepend_before_filter :require_no_authentication
|
||||
prepend_before_action :require_no_authentication
|
||||
|
||||
# GET /resource/unlock/new
|
||||
def new
|
||||
@@ -9,9 +11,10 @@ class Devise::UnlocksController < DeviseController
|
||||
# POST /resource/unlock
|
||||
def create
|
||||
self.resource = resource_class.send_unlock_instructions(resource_params)
|
||||
yield resource if block_given?
|
||||
|
||||
if successfully_sent?(resource)
|
||||
respond_with({}, :location => after_sending_unlock_instructions_path_for(resource))
|
||||
respond_with({}, location: after_sending_unlock_instructions_path_for(resource))
|
||||
else
|
||||
respond_with(resource)
|
||||
end
|
||||
@@ -20,12 +23,13 @@ class Devise::UnlocksController < DeviseController
|
||||
# GET /resource/unlock?unlock_token=abcdef
|
||||
def show
|
||||
self.resource = resource_class.unlock_access_by_token(params[:unlock_token])
|
||||
yield resource if block_given?
|
||||
|
||||
if resource.errors.empty?
|
||||
set_flash_message :notice, :unlocked if is_navigational_format?
|
||||
set_flash_message! :notice, :unlocked
|
||||
respond_with_navigational(resource){ redirect_to after_unlock_path_for(resource) }
|
||||
else
|
||||
respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new }
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,4 +45,7 @@ class Devise::UnlocksController < DeviseController
|
||||
new_session_path(resource) if is_navigational_format?
|
||||
end
|
||||
|
||||
def translation_scope
|
||||
'devise.unlocks'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,17 +1,39 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# All Devise controllers are inherited from here.
|
||||
class DeviseController < Devise.parent_controller.constantize
|
||||
include Devise::Controllers::ScopedViews
|
||||
|
||||
helper DeviseHelper
|
||||
if respond_to?(:helper)
|
||||
helper DeviseHelper
|
||||
end
|
||||
|
||||
helpers = %w(resource scope_name resource_name signed_in_resource
|
||||
resource_class resource_params devise_mapping)
|
||||
hide_action *helpers
|
||||
helper_method *helpers
|
||||
if respond_to?(:helper_method)
|
||||
helpers = %w(resource scope_name resource_name signed_in_resource
|
||||
resource_class resource_params devise_mapping)
|
||||
helper_method(*helpers)
|
||||
end
|
||||
|
||||
prepend_before_filter :assert_is_devise_resource!
|
||||
prepend_before_action :assert_is_devise_resource!
|
||||
respond_to :html if mimes_for_respond_to.empty?
|
||||
|
||||
# Override prefixes to consider the scoped view.
|
||||
# Notice we need to check for the request due to a bug in
|
||||
# Action Controller tests that forces _prefixes to be
|
||||
# loaded before even having a request object.
|
||||
#
|
||||
# This method should be public as it is in ActionPack
|
||||
# itself. Changing its visibility may break other gems.
|
||||
def _prefixes #:nodoc:
|
||||
@_prefixes ||= if self.class.scoped_views? && request && devise_mapping
|
||||
["#{devise_mapping.scoped_path}/#{controller_name}"] + super
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Gets the actual resource stored in the instance variable
|
||||
def resource
|
||||
instance_variable_get(:"@#{resource_name}")
|
||||
@@ -30,7 +52,7 @@ class DeviseController < Devise.parent_controller.constantize
|
||||
|
||||
# Returns a signed in resource from session (if one exists)
|
||||
def signed_in_resource
|
||||
warden.authenticate(:scope => resource_name)
|
||||
warden.authenticate(scope: resource_name)
|
||||
end
|
||||
|
||||
# Attempt to find the mapped route for devise based on request path
|
||||
@@ -38,22 +60,6 @@ class DeviseController < Devise.parent_controller.constantize
|
||||
@devise_mapping ||= request.env["devise.mapping"]
|
||||
end
|
||||
|
||||
# Override prefixes to consider the scoped view.
|
||||
# Notice we need to check for the request due to a bug in
|
||||
# Action Controller tests that forces _prefixes to be
|
||||
# loaded before even having a request object.
|
||||
def _prefixes #:nodoc:
|
||||
@_prefixes ||= if self.class.scoped_views? && request && devise_mapping
|
||||
super.unshift("#{devise_mapping.scoped_path}/#{controller_name}")
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
hide_action :_prefixes
|
||||
|
||||
protected
|
||||
|
||||
# Checks whether it's a devise mapped resource or not.
|
||||
def assert_is_devise_resource! #:nodoc:
|
||||
unknown_action! <<-MESSAGE unless devise_mapping
|
||||
@@ -89,17 +95,17 @@ MESSAGE
|
||||
instance_variable_set(:"@#{resource_name}", new_resource)
|
||||
end
|
||||
|
||||
# Helper for use in before_filters where no authentication is required.
|
||||
# Helper for use in before_actions where no authentication is required.
|
||||
#
|
||||
# Example:
|
||||
# before_filter :require_no_authentication, :only => :new
|
||||
# before_action :require_no_authentication, only: :new
|
||||
def require_no_authentication
|
||||
assert_is_devise_resource!
|
||||
return unless is_navigational_format?
|
||||
no_input = devise_mapping.no_input_strategies
|
||||
|
||||
authenticated = if no_input.present?
|
||||
args = no_input.dup.push :scope => resource_name
|
||||
args = no_input.dup.push scope: resource_name
|
||||
warden.authenticate?(*args)
|
||||
else
|
||||
warden.authenticated?(resource_name)
|
||||
@@ -123,14 +129,17 @@ MESSAGE
|
||||
end
|
||||
|
||||
if notice
|
||||
set_flash_message :notice, notice if is_navigational_format?
|
||||
set_flash_message! :notice, notice
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
# Sets the flash message with :key, using I18n. By default you are able
|
||||
# to setup your messages using specific resource scope, and if no one is
|
||||
# found we look to default scope.
|
||||
# to set up your messages using specific resource scope, and if no message is
|
||||
# found we look to the default scope. Set the "now" options key to a true
|
||||
# value to populate the flash.now hash in lieu of the default flash hash (so
|
||||
# the flash message will be available to the current action instead of the
|
||||
# next action).
|
||||
# Example (i18n locale file):
|
||||
#
|
||||
# en:
|
||||
@@ -144,18 +153,47 @@ MESSAGE
|
||||
# available.
|
||||
def set_flash_message(key, kind, options = {})
|
||||
message = find_message(kind, options)
|
||||
flash[key] = message if message.present?
|
||||
if options[:now]
|
||||
flash.now[key] = message if message.present?
|
||||
else
|
||||
flash[key] = message if message.present?
|
||||
end
|
||||
end
|
||||
|
||||
# Sets flash message if is_flashing_format? equals true
|
||||
def set_flash_message!(key, kind, options = {})
|
||||
if is_flashing_format?
|
||||
set_flash_message(key, kind, options)
|
||||
end
|
||||
end
|
||||
|
||||
# Sets minimum password length to show to user
|
||||
def set_minimum_password_length
|
||||
if devise_mapping.validatable?
|
||||
@minimum_password_length = resource_class.password_length.min
|
||||
end
|
||||
end
|
||||
|
||||
def devise_i18n_options(options)
|
||||
options
|
||||
end
|
||||
|
||||
# Get message for given
|
||||
def find_message(kind, options = {})
|
||||
options[:scope] = "devise.#{controller_name}"
|
||||
options[:scope] ||= translation_scope
|
||||
options[:default] = Array(options[:default]).unshift(kind.to_sym)
|
||||
options[:resource_name] = resource_name
|
||||
options = devise_i18n_options(options) if respond_to?(:devise_i18n_options, true)
|
||||
options = devise_i18n_options(options)
|
||||
I18n.t("#{options[:resource_name]}.#{kind}", options)
|
||||
end
|
||||
|
||||
# Controllers inheriting DeviseController are advised to override this
|
||||
# method so that other controllers inheriting from them would use
|
||||
# existing translations.
|
||||
def translation_scope
|
||||
"devise.#{controller_name}"
|
||||
end
|
||||
|
||||
def clean_up_passwords(object)
|
||||
object.clean_up_passwords if object.respond_to?(:clean_up_passwords)
|
||||
end
|
||||
@@ -169,4 +207,6 @@ MESSAGE
|
||||
def resource_params
|
||||
params.fetch(resource_name, {})
|
||||
end
|
||||
|
||||
ActiveSupport.run_load_hooks(:devise_controller, self)
|
||||
end
|
||||
|
||||
@@ -1,25 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module DeviseHelper
|
||||
# A simple way to show error messages for the current devise resource. If you need
|
||||
# to customize this method, you can either overwrite it in your application helpers or
|
||||
# copy the views to your application.
|
||||
#
|
||||
# This method is intended to stay simple and it is unlikely that we are going to change
|
||||
# it to add more behavior or options.
|
||||
# Retain this method for backwards compatibility, deprecated in favour of modifying the
|
||||
# devise/shared/error_messages partial
|
||||
def devise_error_messages!
|
||||
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
|
||||
[Devise] `DeviseHelper.devise_error_messages!`
|
||||
is deprecated and it will be removed in the next major version.
|
||||
To customize the errors styles please run `rails g devise:views` and modify the
|
||||
`devise/shared/error_messages` partial.
|
||||
DEPRECATION
|
||||
|
||||
return "" if resource.errors.empty?
|
||||
|
||||
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
|
||||
sentence = I18n.t("errors.messages.not_saved",
|
||||
:count => resource.errors.count,
|
||||
:resource => resource.class.model_name.human.downcase)
|
||||
|
||||
html = <<-HTML
|
||||
<div id="error_explanation">
|
||||
<h2>#{sentence}</h2>
|
||||
<ul>#{messages}</ul>
|
||||
</div>
|
||||
HTML
|
||||
|
||||
html.html_safe
|
||||
render "devise/shared/error_messages", resource: resource
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,18 +1,30 @@
|
||||
class Devise::Mailer < Devise.parent_mailer.constantize
|
||||
include Devise::Mailers::Helpers
|
||||
# frozen_string_literal: true
|
||||
|
||||
def confirmation_instructions(record, token, opts={})
|
||||
@token = token
|
||||
devise_mail(record, :confirmation_instructions, opts)
|
||||
end
|
||||
if defined?(ActionMailer)
|
||||
class Devise::Mailer < Devise.parent_mailer.constantize
|
||||
include Devise::Mailers::Helpers
|
||||
|
||||
def reset_password_instructions(record, token, opts={})
|
||||
@token = token
|
||||
devise_mail(record, :reset_password_instructions, opts)
|
||||
end
|
||||
def confirmation_instructions(record, token, opts={})
|
||||
@token = token
|
||||
devise_mail(record, :confirmation_instructions, opts)
|
||||
end
|
||||
|
||||
def unlock_instructions(record, token, opts={})
|
||||
@token = token
|
||||
devise_mail(record, :unlock_instructions, opts)
|
||||
def reset_password_instructions(record, token, opts={})
|
||||
@token = token
|
||||
devise_mail(record, :reset_password_instructions, opts)
|
||||
end
|
||||
|
||||
def unlock_instructions(record, token, opts={})
|
||||
@token = token
|
||||
devise_mail(record, :unlock_instructions, opts)
|
||||
end
|
||||
|
||||
def email_changed(record, opts={})
|
||||
devise_mail(record, :email_changed, opts)
|
||||
end
|
||||
|
||||
def password_change(record, opts={})
|
||||
devise_mail(record, :password_change, opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
<h2>Resend confirmation instructions</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
|
||||
<%= render "devise/shared/error_messages", resource: resource %>
|
||||
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email, :autofocus => true %></div>
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
|
||||
</div>
|
||||
|
||||
<div><%= f.submit "Resend confirmation instructions" %></div>
|
||||
<div class="actions">
|
||||
<%= f.submit "Resend confirmation instructions" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "devise/shared/links" %>
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
<p>You can confirm your account email through the link below:</p>
|
||||
|
||||
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @token) %></p>
|
||||
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
|
||||
|
||||
7
app/views/devise/mailer/email_changed.html.erb
Normal file
7
app/views/devise/mailer/email_changed.html.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<p>Hello <%= @email %>!</p>
|
||||
|
||||
<% if @resource.try(:unconfirmed_email?) %>
|
||||
<p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
|
||||
<% else %>
|
||||
<p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
|
||||
<% end %>
|
||||
3
app/views/devise/mailer/password_change.html.erb
Normal file
3
app/views/devise/mailer/password_change.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<p>Hello <%= @resource.email %>!</p>
|
||||
|
||||
<p>We're contacting you to notify you that your password has been changed.</p>
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
|
||||
|
||||
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @token) %></p>
|
||||
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
|
||||
|
||||
<p>If you didn't request this, please ignore this email.</p>
|
||||
<p>Your password won't change until you access the link above and create a new one.</p>
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
|
||||
<p>Click the link below to unlock your account:</p>
|
||||
|
||||
<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @token) %></p>
|
||||
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
<h2>Change your password</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
|
||||
<%= render "devise/shared/error_messages", resource: resource %>
|
||||
<%= f.hidden_field :reset_password_token %>
|
||||
|
||||
<div><%= f.label :password, "New password" %><br />
|
||||
<%= f.password_field :password, :autofocus => true %></div>
|
||||
<div class="field">
|
||||
<%= f.label :password, "New password" %><br />
|
||||
<% if @minimum_password_length %>
|
||||
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
|
||||
<% end %>
|
||||
<%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
|
||||
</div>
|
||||
|
||||
<div><%= f.label :password_confirmation, "Confirm new password" %><br />
|
||||
<%= f.password_field :password_confirmation %></div>
|
||||
<div class="field">
|
||||
<%= f.label :password_confirmation, "Confirm new password" %><br />
|
||||
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
|
||||
</div>
|
||||
|
||||
<div><%= f.submit "Change my password" %></div>
|
||||
<div class="actions">
|
||||
<%= f.submit "Change my password" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "devise/shared/links" %>
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
<h2>Forgot your password?</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
|
||||
<%= render "devise/shared/error_messages", resource: resource %>
|
||||
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email, :autofocus => true %></div>
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
|
||||
</div>
|
||||
|
||||
<div><%= f.submit "Send me reset password instructions" %></div>
|
||||
<div class="actions">
|
||||
<%= f.submit "Send me reset password instructions" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "devise/shared/links" %>
|
||||
|
||||
@@ -1,29 +1,43 @@
|
||||
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
|
||||
<%= render "devise/shared/error_messages", resource: resource %>
|
||||
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email, :autofocus => true %></div>
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
|
||||
</div>
|
||||
|
||||
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
|
||||
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
|
||||
<% end %>
|
||||
|
||||
<div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
|
||||
<%= f.password_field :password, :autocomplete => "off" %></div>
|
||||
<div class="field">
|
||||
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
|
||||
<%= f.password_field :password, autocomplete: "new-password" %>
|
||||
<% if @minimum_password_length %>
|
||||
<br />
|
||||
<em><%= @minimum_password_length %> characters minimum</em>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div><%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation %></div>
|
||||
<div class="field">
|
||||
<%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
|
||||
</div>
|
||||
|
||||
<div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
|
||||
<%= f.password_field :current_password %></div>
|
||||
<div class="field">
|
||||
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
|
||||
<%= f.password_field :current_password, autocomplete: "current-password" %>
|
||||
</div>
|
||||
|
||||
<div><%= f.submit "Update" %></div>
|
||||
<div class="actions">
|
||||
<%= f.submit "Update" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<h3>Cancel my account</h3>
|
||||
|
||||
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %></p>
|
||||
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
|
||||
|
||||
<%= link_to "Back", :back %>
|
||||
|
||||
@@ -1,18 +1,29 @@
|
||||
<h2>Sign up</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
|
||||
<%= render "devise/shared/error_messages", resource: resource %>
|
||||
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email, :autofocus => true %></div>
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
|
||||
</div>
|
||||
|
||||
<div><%= f.label :password %><br />
|
||||
<%= f.password_field :password %></div>
|
||||
<div class="field">
|
||||
<%= f.label :password %>
|
||||
<% if @minimum_password_length %>
|
||||
<em>(<%= @minimum_password_length %> characters minimum)</em>
|
||||
<% end %><br />
|
||||
<%= f.password_field :password, autocomplete: "new-password" %>
|
||||
</div>
|
||||
|
||||
<div><%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation %></div>
|
||||
<div class="field">
|
||||
<%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
|
||||
</div>
|
||||
|
||||
<div><%= f.submit "Sign up" %></div>
|
||||
<div class="actions">
|
||||
<%= f.submit "Sign up" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "devise/shared/links" %>
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
<h2>Sign in</h2>
|
||||
<h2>Log in</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email, :autofocus => true %></div>
|
||||
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
|
||||
</div>
|
||||
|
||||
<div><%= f.label :password %><br />
|
||||
<%= f.password_field :password %></div>
|
||||
<div class="field">
|
||||
<%= f.label :password %><br />
|
||||
<%= f.password_field :password, autocomplete: "current-password" %>
|
||||
</div>
|
||||
|
||||
<% if devise_mapping.rememberable? -%>
|
||||
<div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
|
||||
<% end -%>
|
||||
<% if devise_mapping.rememberable? %>
|
||||
<div class="field">
|
||||
<%= f.check_box :remember_me %>
|
||||
<%= f.label :remember_me %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div><%= f.submit "Sign in" %></div>
|
||||
<div class="actions">
|
||||
<%= f.submit "Log in" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "devise/shared/links" %>
|
||||
|
||||
15
app/views/devise/shared/_error_messages.html.erb
Normal file
15
app/views/devise/shared/_error_messages.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<% if resource.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2>
|
||||
<%= I18n.t("errors.messages.not_saved",
|
||||
count: resource.errors.count,
|
||||
resource: resource.class.model_name.human.downcase)
|
||||
%>
|
||||
</h2>
|
||||
<ul>
|
||||
<% resource.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,25 +1,25 @@
|
||||
<%- if controller_name != 'sessions' %>
|
||||
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
<%= link_to "Log in", new_session_path(resource_name) %><br />
|
||||
<% end %>
|
||||
|
||||
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
||||
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
<% end %>
|
||||
|
||||
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
|
||||
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
<% end %>
|
||||
|
||||
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
||||
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
<% end %>
|
||||
|
||||
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
||||
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
<% end %>
|
||||
|
||||
<%- if devise_mapping.omniauthable? %>
|
||||
<%- resource_class.omniauth_providers.each do |provider| %>
|
||||
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -1,12 +1,16 @@
|
||||
<h2>Resend unlock instructions</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
|
||||
<%= render "devise/shared/error_messages", resource: resource %>
|
||||
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email, :autofocus => true %></div>
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
|
||||
</div>
|
||||
|
||||
<div><%= f.submit "Resend unlock instructions" %></div>
|
||||
<div class="actions">
|
||||
<%= f.submit "Resend unlock instructions" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "devise/shared/links" %>
|
||||
|
||||
17
bin/test
Executable file
17
bin/test
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env ruby
|
||||
$: << File.expand_path(File.expand_path('../../test', __FILE__))
|
||||
|
||||
# Remove this begin/rescue once Rails 4 support is removed.
|
||||
begin
|
||||
require 'bundler/setup'
|
||||
require 'rails/test_unit/runner'
|
||||
require 'rails/test_unit/reporter'
|
||||
require 'rails/test_unit/line_filtering'
|
||||
|
||||
Rails::TestUnitReporter.executable = 'bin/test'
|
||||
|
||||
Rails::TestUnit::Runner.parse_options(ARGV)
|
||||
Rails::TestUnit::Runner.run(ARGV)
|
||||
rescue LoadError
|
||||
exec 'rake'
|
||||
end
|
||||
@@ -3,50 +3,55 @@
|
||||
en:
|
||||
devise:
|
||||
confirmations:
|
||||
confirmed: "Your account was successfully confirmed. Please sign in."
|
||||
confirmed_and_signed_in: "Your account was successfully confirmed. You are now signed in."
|
||||
send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
|
||||
send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."
|
||||
confirmed: "Your email address has been successfully confirmed."
|
||||
send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
|
||||
send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
|
||||
failure:
|
||||
already_authenticated: "You are already signed in."
|
||||
inactive: "Your account is not activated yet."
|
||||
invalid: "Invalid email or password."
|
||||
invalid_token: "Invalid authentication token."
|
||||
invalid: "Invalid %{authentication_keys} or password."
|
||||
locked: "Your account is locked."
|
||||
not_found_in_database: "Invalid email or password."
|
||||
last_attempt: "You have one more attempt before your account is locked."
|
||||
not_found_in_database: "Invalid %{authentication_keys} or password."
|
||||
timeout: "Your session expired. Please sign in again to continue."
|
||||
unauthenticated: "You need to sign in or sign up before continuing."
|
||||
unconfirmed: "You have to confirm your account before continuing."
|
||||
unconfirmed: "You have to confirm your email address before continuing."
|
||||
mailer:
|
||||
confirmation_instructions:
|
||||
subject: "Confirmation instructions"
|
||||
reset_password_instructions:
|
||||
subject: "Reset password instructions"
|
||||
unlock_instructions:
|
||||
subject: "Unlock Instructions"
|
||||
subject: "Unlock instructions"
|
||||
email_changed:
|
||||
subject: "Email Changed"
|
||||
password_change:
|
||||
subject: "Password Changed"
|
||||
omniauth_callbacks:
|
||||
failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
|
||||
success: "Successfully authenticated from %{kind} account."
|
||||
passwords:
|
||||
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
|
||||
send_instructions: "You will receive an email with instructions about how to reset your password in a few minutes."
|
||||
send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
|
||||
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
|
||||
updated: "Your password was changed successfully. You are now signed in."
|
||||
updated_not_active: "Your password was changed successfully."
|
||||
updated: "Your password has been changed successfully. You are now signed in."
|
||||
updated_not_active: "Your password has been changed successfully."
|
||||
registrations:
|
||||
destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon."
|
||||
destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
|
||||
signed_up: "Welcome! You have signed up successfully."
|
||||
signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
|
||||
signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
|
||||
signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account."
|
||||
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
|
||||
updated: "You updated your account successfully."
|
||||
signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
|
||||
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
|
||||
updated: "Your account has been updated successfully."
|
||||
updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again"
|
||||
sessions:
|
||||
signed_in: "Signed in successfully."
|
||||
signed_out: "Signed out successfully."
|
||||
already_signed_out: "Signed out successfully."
|
||||
unlocks:
|
||||
send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes."
|
||||
send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
|
||||
send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
|
||||
send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
|
||||
unlocked: "Your account has been unlocked successfully. Please sign in to continue."
|
||||
errors:
|
||||
messages:
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# frozen_string_literal: true
|
||||
|
||||
$:.push File.expand_path("../lib", __FILE__)
|
||||
require "devise/version"
|
||||
|
||||
@@ -9,19 +11,17 @@ Gem::Specification.new do |s|
|
||||
s.licenses = ["MIT"]
|
||||
s.summary = "Flexible authentication solution for Rails with Warden"
|
||||
s.email = "contact@plataformatec.com.br"
|
||||
s.homepage = "http://github.com/plataformatec/devise"
|
||||
s.homepage = "https://github.com/plataformatec/devise"
|
||||
s.description = "Flexible authentication solution for Rails with Warden"
|
||||
s.authors = ['José Valim', 'Carlos Antônio']
|
||||
|
||||
s.rubyforge_project = "devise"
|
||||
|
||||
s.files = `git ls-files`.split("\n")
|
||||
s.test_files = `git ls-files -- test/*`.split("\n")
|
||||
s.files = Dir["{app,config,lib}/**/*", "CHANGELOG.md", "MIT-LICENSE", "README.md"]
|
||||
s.require_paths = ["lib"]
|
||||
s.required_ruby_version = '>= 2.1.0'
|
||||
|
||||
s.add_dependency("warden", "~> 1.2.3")
|
||||
s.add_dependency("orm_adapter", "~> 0.1")
|
||||
s.add_dependency("bcrypt-ruby", "~> 3.0")
|
||||
s.add_dependency("thread_safe", "~> 0.1")
|
||||
s.add_dependency("railties", ">= 3.2.6", "< 5")
|
||||
s.add_dependency("bcrypt", "~> 3.0")
|
||||
s.add_dependency("railties", ">= 4.1.0")
|
||||
s.add_dependency("responders")
|
||||
end
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec :path => '..'
|
||||
|
||||
gem "rails", "~> 3.2.6"
|
||||
gem "omniauth", "~> 1.0.0"
|
||||
gem "omniauth-oauth2", "~> 1.0.0"
|
||||
gem "rdoc"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", :require => false
|
||||
gem "mocha", "~> 0.13.1", :require => false
|
||||
end
|
||||
|
||||
platforms :jruby do
|
||||
gem "activerecord-jdbc-adapter"
|
||||
gem "activerecord-jdbcsqlite3-adapter"
|
||||
gem "jruby-openssl"
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3"
|
||||
end
|
||||
|
||||
platforms :mri_19, :mri_20 do
|
||||
group :mongoid do
|
||||
gem "mongoid", "~> 3.0"
|
||||
end
|
||||
end
|
||||
@@ -1,159 +0,0 @@
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (3.1.0)
|
||||
bcrypt-ruby (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 3.2.6, < 5)
|
||||
thread_safe (~> 0.1)
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (3.2.14)
|
||||
actionpack (= 3.2.14)
|
||||
mail (~> 2.5.4)
|
||||
actionpack (3.2.14)
|
||||
activemodel (= 3.2.14)
|
||||
activesupport (= 3.2.14)
|
||||
builder (~> 3.0.0)
|
||||
erubis (~> 2.7.0)
|
||||
journey (~> 1.0.4)
|
||||
rack (~> 1.4.5)
|
||||
rack-cache (~> 1.2)
|
||||
rack-test (~> 0.6.1)
|
||||
sprockets (~> 2.2.1)
|
||||
activemodel (3.2.14)
|
||||
activesupport (= 3.2.14)
|
||||
builder (~> 3.0.0)
|
||||
activerecord (3.2.14)
|
||||
activemodel (= 3.2.14)
|
||||
activesupport (= 3.2.14)
|
||||
arel (~> 3.0.2)
|
||||
tzinfo (~> 0.3.29)
|
||||
activeresource (3.2.14)
|
||||
activemodel (= 3.2.14)
|
||||
activesupport (= 3.2.14)
|
||||
activesupport (3.2.14)
|
||||
i18n (~> 0.6, >= 0.6.4)
|
||||
multi_json (~> 1.0)
|
||||
arel (3.0.2)
|
||||
atomic (1.1.13)
|
||||
bcrypt-ruby (3.1.1)
|
||||
builder (3.0.4)
|
||||
erubis (2.7.0)
|
||||
faraday (0.8.8)
|
||||
multipart-post (~> 1.2.0)
|
||||
hashie (1.2.0)
|
||||
hike (1.2.3)
|
||||
httpauth (0.2.0)
|
||||
i18n (0.6.5)
|
||||
journey (1.0.4)
|
||||
json (1.8.0)
|
||||
jwt (0.1.8)
|
||||
multi_json (>= 1.5)
|
||||
mail (2.5.4)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
metaclass (0.0.1)
|
||||
mime-types (1.23)
|
||||
mocha (0.13.3)
|
||||
metaclass (~> 0.0.1)
|
||||
mongoid (3.1.4)
|
||||
activemodel (~> 3.2)
|
||||
moped (~> 1.4)
|
||||
origin (~> 1.0)
|
||||
tzinfo (~> 0.3.22)
|
||||
moped (1.5.1)
|
||||
multi_json (1.7.9)
|
||||
multipart-post (1.2.0)
|
||||
nokogiri (1.5.9)
|
||||
oauth2 (0.8.1)
|
||||
faraday (~> 0.8)
|
||||
httpauth (~> 0.1)
|
||||
jwt (~> 0.1.4)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.2)
|
||||
omniauth (1.0.3)
|
||||
hashie (~> 1.2)
|
||||
rack
|
||||
omniauth-facebook (1.4.0)
|
||||
omniauth-oauth2 (~> 1.0.2)
|
||||
omniauth-oauth2 (1.0.3)
|
||||
oauth2 (~> 0.8.0)
|
||||
omniauth (~> 1.0)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
origin (1.1.0)
|
||||
orm_adapter (0.4.0)
|
||||
polyglot (0.3.3)
|
||||
rack (1.4.5)
|
||||
rack-cache (1.2)
|
||||
rack (>= 0.4)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-ssl (1.3.3)
|
||||
rack
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
rails (3.2.14)
|
||||
actionmailer (= 3.2.14)
|
||||
actionpack (= 3.2.14)
|
||||
activerecord (= 3.2.14)
|
||||
activeresource (= 3.2.14)
|
||||
activesupport (= 3.2.14)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.2.14)
|
||||
railties (3.2.14)
|
||||
actionpack (= 3.2.14)
|
||||
activesupport (= 3.2.14)
|
||||
rack-ssl (~> 1.3.2)
|
||||
rake (>= 0.8.7)
|
||||
rdoc (~> 3.4)
|
||||
thor (>= 0.14.6, < 2.0)
|
||||
rake (10.1.0)
|
||||
rdoc (3.12.2)
|
||||
json (~> 1.4)
|
||||
ruby-openid (2.2.3)
|
||||
sprockets (2.2.2)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
sqlite3 (1.3.7)
|
||||
thor (0.18.1)
|
||||
thread_safe (0.1.2)
|
||||
atomic
|
||||
tilt (1.4.1)
|
||||
treetop (1.4.14)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.37)
|
||||
warden (1.2.3)
|
||||
rack (>= 1.0)
|
||||
webrat (0.7.3)
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activerecord-jdbc-adapter
|
||||
activerecord-jdbcsqlite3-adapter
|
||||
devise!
|
||||
jruby-openssl
|
||||
mocha (~> 0.13.1)
|
||||
mongoid (~> 3.0)
|
||||
omniauth (~> 1.0.0)
|
||||
omniauth-facebook
|
||||
omniauth-oauth2 (~> 1.0.0)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
rails (~> 3.2.6)
|
||||
rdoc
|
||||
sqlite3
|
||||
webrat (= 0.7.3)
|
||||
35
gemfiles/Gemfile.rails-4.1-stable
Normal file
35
gemfiles/Gemfile.rails-4.1-stable
Normal file
@@ -0,0 +1,35 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: ".."
|
||||
|
||||
gem "rails", github: "rails/rails", branch: "4-1-stable"
|
||||
gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc", "~> 5.1"
|
||||
# Force this version because it's breaking on CI since a higher nokogiri version requires Ruby 2.3+.
|
||||
gem "nokogiri", "1.9.1"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
end
|
||||
|
||||
platforms :jruby do
|
||||
gem "activerecord-jdbc-adapter"
|
||||
gem "activerecord-jdbcsqlite3-adapter"
|
||||
gem "jruby-openssl"
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3", "~> 1.3.6"
|
||||
end
|
||||
|
||||
group :mongoid do
|
||||
gem "mongoid", "~> 4.0"
|
||||
end
|
||||
174
gemfiles/Gemfile.rails-4.1-stable.lock
Normal file
174
gemfiles/Gemfile.rails-4.1-stable.lock
Normal file
@@ -0,0 +1,174 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/rails.git
|
||||
revision: 0cad778c2605a5204a05a9f1dbd3344e39f248d8
|
||||
branch: 4-1-stable
|
||||
specs:
|
||||
actionmailer (4.1.16)
|
||||
actionpack (= 4.1.16)
|
||||
actionview (= 4.1.16)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails (4.1.16)
|
||||
actionmailer (= 4.1.16)
|
||||
actionpack (= 4.1.16)
|
||||
actionview (= 4.1.16)
|
||||
activemodel (= 4.1.16)
|
||||
activerecord (= 4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.1.16)
|
||||
sprockets-rails (~> 2.0)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.6.2)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0, < 6.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionpack (4.1.16)
|
||||
actionview (= 4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
rack (~> 1.5.2)
|
||||
rack-test (~> 0.6.2)
|
||||
actionview (4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
activemodel (4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.1.16)
|
||||
activemodel (= 4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
arel (~> 5.0.0)
|
||||
activesupport (4.1.16)
|
||||
i18n (~> 0.6, >= 0.6.9)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (5.0.1.20140414130214)
|
||||
bcrypt (3.1.12)
|
||||
bson (3.2.6)
|
||||
builder (3.2.3)
|
||||
concurrent-ruby (1.0.5)
|
||||
connection_pool (2.2.1)
|
||||
erubis (2.7.0)
|
||||
faraday (0.11.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
hashie (3.5.5)
|
||||
i18n (0.8.1)
|
||||
json (1.8.6)
|
||||
jwt (1.5.6)
|
||||
mail (2.6.4)
|
||||
mime-types (>= 1.16, < 4)
|
||||
metaclass (0.0.4)
|
||||
mime-types (3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.10.1)
|
||||
mocha (1.2.1)
|
||||
metaclass (~> 0.0.1)
|
||||
mongoid (4.0.2)
|
||||
activemodel (~> 4.0)
|
||||
moped (~> 2.0.0)
|
||||
origin (~> 2.1)
|
||||
tzinfo (>= 0.3.37)
|
||||
moped (2.0.7)
|
||||
bson (~> 3.0)
|
||||
connection_pool (~> 2.0)
|
||||
optionable (~> 0.2.0)
|
||||
multi_json (1.12.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.9.1)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.3.1)
|
||||
faraday (>= 0.8, < 0.12)
|
||||
jwt (~> 1.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.4.2)
|
||||
hashie (>= 1.2, < 4)
|
||||
rack (>= 1.0, < 3)
|
||||
omniauth-facebook (4.0.0)
|
||||
omniauth-oauth2 (~> 1.2)
|
||||
omniauth-oauth2 (1.4.0)
|
||||
oauth2 (~> 1.0)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
optionable (0.2.0)
|
||||
origin (2.3.0)
|
||||
orm_adapter (0.5.0)
|
||||
rack (1.5.5)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
railties (4.1.16)
|
||||
actionpack (= 4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (12.0.0)
|
||||
rdoc (5.1.0)
|
||||
responders (1.1.2)
|
||||
railties (>= 3.2, < 4.2)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (3.7.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (2.3.3)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sqlite3 (1.3.13)
|
||||
test_after_commit (1.1.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.19.4)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.8.1)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.7)
|
||||
rack (>= 1.0)
|
||||
webrat (0.7.3)
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activerecord-jdbc-adapter
|
||||
activerecord-jdbcsqlite3-adapter
|
||||
devise!
|
||||
jruby-openssl
|
||||
mocha (~> 1.1)
|
||||
mongoid (~> 4.0)
|
||||
nokogiri (= 1.9.1)
|
||||
omniauth
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails!
|
||||
rdoc (~> 5.1)
|
||||
sqlite3 (~> 1.3.6)
|
||||
test_after_commit
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
34
gemfiles/Gemfile.rails-4.2-stable
Normal file
34
gemfiles/Gemfile.rails-4.2-stable
Normal file
@@ -0,0 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: ".."
|
||||
|
||||
gem "rails", github: "rails/rails", branch: "4-2-stable"
|
||||
gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc", "~> 5.1"
|
||||
gem "nokogiri", "1.9.1"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
end
|
||||
|
||||
platforms :jruby do
|
||||
gem "activerecord-jdbc-adapter"
|
||||
gem "activerecord-jdbcsqlite3-adapter"
|
||||
gem "jruby-openssl"
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3", "~> 1.3.6"
|
||||
end
|
||||
|
||||
group :mongoid do
|
||||
gem "mongoid", "~> 4.0"
|
||||
end
|
||||
195
gemfiles/Gemfile.rails-4.2-stable.lock
Normal file
195
gemfiles/Gemfile.rails-4.2-stable.lock
Normal file
@@ -0,0 +1,195 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/rails.git
|
||||
revision: dc3ae21802c316e1639239d28202db7aa7fb7cac
|
||||
branch: 4-2-stable
|
||||
specs:
|
||||
actionmailer (4.2.8)
|
||||
actionpack (= 4.2.8)
|
||||
actionview (= 4.2.8)
|
||||
activejob (= 4.2.8)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
actionpack (4.2.8)
|
||||
actionview (= 4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
rack (~> 1.6)
|
||||
rack-test (~> 0.6.2)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
globalid (>= 0.3.0)
|
||||
activemodel (4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.2.8)
|
||||
activemodel (= 4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
arel (~> 6.0)
|
||||
activesupport (4.2.8)
|
||||
i18n (~> 0.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
rails (4.2.8)
|
||||
actionmailer (= 4.2.8)
|
||||
actionpack (= 4.2.8)
|
||||
actionview (= 4.2.8)
|
||||
activejob (= 4.2.8)
|
||||
activemodel (= 4.2.8)
|
||||
activerecord (= 4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.2.8)
|
||||
sprockets-rails
|
||||
railties (4.2.8)
|
||||
actionpack (= 4.2.8)
|
||||
activesupport (= 4.2.8)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.6.2)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0, < 6.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
arel (6.0.4)
|
||||
bcrypt (3.1.12)
|
||||
bson (3.2.6)
|
||||
builder (3.2.3)
|
||||
concurrent-ruby (1.0.5)
|
||||
connection_pool (2.2.1)
|
||||
erubis (2.7.0)
|
||||
faraday (0.11.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.3.7)
|
||||
activesupport (>= 4.1.0)
|
||||
hashie (3.5.5)
|
||||
i18n (0.8.1)
|
||||
jwt (1.5.6)
|
||||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.4)
|
||||
mime-types (>= 1.16, < 4)
|
||||
metaclass (0.0.4)
|
||||
mime-types (3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.10.1)
|
||||
mocha (1.2.1)
|
||||
metaclass (~> 0.0.1)
|
||||
mongoid (4.0.2)
|
||||
activemodel (~> 4.0)
|
||||
moped (~> 2.0.0)
|
||||
origin (~> 2.1)
|
||||
tzinfo (>= 0.3.37)
|
||||
moped (2.0.7)
|
||||
bson (~> 3.0)
|
||||
connection_pool (~> 2.0)
|
||||
optionable (~> 0.2.0)
|
||||
multi_json (1.12.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.9.1)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.3.1)
|
||||
faraday (>= 0.8, < 0.12)
|
||||
jwt (~> 1.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.6.1)
|
||||
hashie (>= 3.4.6, < 3.6.0)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (4.0.0)
|
||||
omniauth-oauth2 (~> 1.2)
|
||||
omniauth-oauth2 (1.4.0)
|
||||
oauth2 (~> 1.0)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
optionable (0.2.0)
|
||||
origin (2.3.0)
|
||||
orm_adapter (0.5.0)
|
||||
rack (1.6.5)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails-deprecated_sanitizer (1.0.3)
|
||||
activesupport (>= 4.2.0.alpha)
|
||||
rails-dom-testing (1.0.8)
|
||||
activesupport (>= 4.2.0.beta, < 5.0)
|
||||
nokogiri (~> 1.6)
|
||||
rails-deprecated_sanitizer (>= 1.0.1)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
rake (12.0.0)
|
||||
rdoc (5.1.0)
|
||||
responders (2.4.1)
|
||||
actionpack (>= 4.2.0, < 6.0)
|
||||
railties (>= 4.2.0, < 6.0)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (3.7.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.0)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
test_after_commit (1.1.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.19.4)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.8.1)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.7)
|
||||
rack (>= 1.0)
|
||||
webrat (0.7.3)
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activerecord-jdbc-adapter
|
||||
activerecord-jdbcsqlite3-adapter
|
||||
devise!
|
||||
jruby-openssl
|
||||
mocha (~> 1.1)
|
||||
mongoid (~> 4.0)
|
||||
nokogiri (= 1.9.1)
|
||||
omniauth
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails!
|
||||
rdoc (~> 5.1)
|
||||
sqlite3 (~> 1.3.6)
|
||||
test_after_commit
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
34
gemfiles/Gemfile.rails-5.0-stable
Normal file
34
gemfiles/Gemfile.rails-5.0-stable
Normal file
@@ -0,0 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: ".."
|
||||
|
||||
gem "rails", '~> 5.0.0'
|
||||
gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc"
|
||||
|
||||
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
|
||||
|
||||
gem "rails-controller-testing"
|
||||
|
||||
gem "responders", "~> 2.1"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3", "~> 1.3.6"
|
||||
end
|
||||
|
||||
# TODO:
|
||||
# group :mongoid do
|
||||
# gem "mongoid", "~> 4.0.0"
|
||||
# end
|
||||
194
gemfiles/Gemfile.rails-5.0-stable.lock
Normal file
194
gemfiles/Gemfile.rails-5.0-stable.lock
Normal file
@@ -0,0 +1,194 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/activemodel-serializers-xml.git
|
||||
revision: dd9c0acf26aab111ebc647cd8deb99ebc6946531
|
||||
specs:
|
||||
activemodel-serializers-xml (1.0.1)
|
||||
activemodel (> 5.x)
|
||||
activesupport (> 5.x)
|
||||
builder (~> 3.1)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.7.0)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.0.2)
|
||||
actionpack (= 5.0.2)
|
||||
nio4r (>= 1.2, < 3.0)
|
||||
websocket-driver (~> 0.6.1)
|
||||
actionmailer (5.0.2)
|
||||
actionpack (= 5.0.2)
|
||||
actionview (= 5.0.2)
|
||||
activejob (= 5.0.2)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.0.2)
|
||||
actionview (= 5.0.2)
|
||||
activesupport (= 5.0.2)
|
||||
rack (~> 2.0)
|
||||
rack-test (~> 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.0.2)
|
||||
activesupport (= 5.0.2)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (5.0.2)
|
||||
activesupport (= 5.0.2)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.0.2)
|
||||
activesupport (= 5.0.2)
|
||||
activerecord (5.0.2)
|
||||
activemodel (= 5.0.2)
|
||||
activesupport (= 5.0.2)
|
||||
arel (~> 7.0)
|
||||
activesupport (5.0.2)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (~> 0.7)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (7.1.4)
|
||||
bcrypt (3.1.13)
|
||||
builder (3.2.3)
|
||||
concurrent-ruby (1.0.5)
|
||||
erubis (2.7.0)
|
||||
faraday (0.11.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.4.0)
|
||||
activesupport (>= 4.2.0)
|
||||
hashie (3.5.5)
|
||||
i18n (0.8.1)
|
||||
jwt (1.5.6)
|
||||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.5)
|
||||
mime-types (>= 1.16, < 4)
|
||||
metaclass (0.0.4)
|
||||
method_source (0.8.2)
|
||||
mime-types (3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_portile2 (2.1.0)
|
||||
minitest (5.10.1)
|
||||
mocha (1.2.1)
|
||||
metaclass (~> 0.0.1)
|
||||
multi_json (1.12.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.0.0)
|
||||
nio4r (2.0.0)
|
||||
nokogiri (1.7.2)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
oauth2 (1.3.1)
|
||||
faraday (>= 0.8, < 0.12)
|
||||
jwt (~> 1.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.6.1)
|
||||
hashie (>= 3.4.6, < 3.6.0)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (4.0.0)
|
||||
omniauth-oauth2 (~> 1.2)
|
||||
omniauth-oauth2 (1.4.0)
|
||||
oauth2 (~> 1.0)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
orm_adapter (0.5.0)
|
||||
rack (2.0.2)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (5.0.2)
|
||||
actioncable (= 5.0.2)
|
||||
actionmailer (= 5.0.2)
|
||||
actionpack (= 5.0.2)
|
||||
actionview (= 5.0.2)
|
||||
activejob (= 5.0.2)
|
||||
activemodel (= 5.0.2)
|
||||
activerecord (= 5.0.2)
|
||||
activesupport (= 5.0.2)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 5.0.2)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-controller-testing (1.0.1)
|
||||
actionpack (~> 5.x)
|
||||
actionview (~> 5.x)
|
||||
activesupport (~> 5.x)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (5.0.2)
|
||||
actionpack (= 5.0.2)
|
||||
activesupport (= 5.0.2)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (12.0.0)
|
||||
rdoc (5.1.0)
|
||||
responders (2.4.0)
|
||||
actionpack (>= 4.2.0, < 5.3)
|
||||
railties (>= 4.2.0, < 5.3)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (3.7.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.0)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
test_after_commit (1.1.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.19.4)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.8.1)
|
||||
tzinfo (1.2.3)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.7)
|
||||
rack (>= 1.0)
|
||||
webrat (0.7.3)
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
websocket-driver (0.6.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activemodel-serializers-xml!
|
||||
devise!
|
||||
mocha (~> 1.1)
|
||||
omniauth
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails (~> 5.0.0)
|
||||
rails-controller-testing
|
||||
rdoc
|
||||
responders (~> 2.1)
|
||||
sqlite3 (~> 1.3.6)
|
||||
test_after_commit
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.1
|
||||
27
gemfiles/Gemfile.rails-5.2-stable
Normal file
27
gemfiles/Gemfile.rails-5.2-stable
Normal file
@@ -0,0 +1,27 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: ".."
|
||||
|
||||
gem "rails", '~> 5.2'
|
||||
gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc"
|
||||
|
||||
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
|
||||
|
||||
gem "rails-controller-testing"
|
||||
|
||||
gem "responders", "~> 2.1"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3", "~> 1.3.6"
|
||||
end
|
||||
203
gemfiles/Gemfile.rails-5.2-stable.lock
Normal file
203
gemfiles/Gemfile.rails-5.2-stable.lock
Normal file
@@ -0,0 +1,203 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/activemodel-serializers-xml.git
|
||||
revision: f744aeca2747ed3134e492249c4ee39b548efdf6
|
||||
specs:
|
||||
activemodel-serializers-xml (1.0.2)
|
||||
activemodel (> 5.x)
|
||||
activesupport (> 5.x)
|
||||
builder (~> 3.1)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.7.0)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailer (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
actionview (= 5.2.1)
|
||||
activejob (= 5.2.1)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.2.1)
|
||||
actionview (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
rack (~> 2.0)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
activerecord (5.2.1)
|
||||
activemodel (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
arel (>= 9.0)
|
||||
activestorage (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
activerecord (= 5.2.1)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (5.2.1)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (9.0.0)
|
||||
bcrypt (3.1.13)
|
||||
builder (3.2.3)
|
||||
concurrent-ruby (1.0.5)
|
||||
crass (1.0.4)
|
||||
erubi (1.7.1)
|
||||
faraday (0.12.2)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.4.1)
|
||||
activesupport (>= 4.2.0)
|
||||
hashie (3.5.7)
|
||||
i18n (1.1.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jwt (1.5.6)
|
||||
loofah (2.2.2)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.0)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.3)
|
||||
mimemagic (~> 0.3.2)
|
||||
metaclass (0.0.4)
|
||||
method_source (0.9.0)
|
||||
mimemagic (0.3.2)
|
||||
mini_mime (1.0.1)
|
||||
mini_portile2 (2.3.0)
|
||||
minitest (5.11.3)
|
||||
mocha (1.7.0)
|
||||
metaclass (~> 0.0.1)
|
||||
multi_json (1.13.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.0.0)
|
||||
nio4r (2.3.1)
|
||||
nokogiri (1.8.5)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
oauth2 (1.4.0)
|
||||
faraday (>= 0.8, < 0.13)
|
||||
jwt (~> 1.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.8.1)
|
||||
hashie (>= 3.4.6, < 3.6.0)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (5.0.0)
|
||||
omniauth-oauth2 (~> 1.2)
|
||||
omniauth-oauth2 (1.5.0)
|
||||
oauth2 (~> 1.1)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
orm_adapter (0.5.0)
|
||||
rack (2.0.5)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.2.1)
|
||||
actioncable (= 5.2.1)
|
||||
actionmailer (= 5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
actionview (= 5.2.1)
|
||||
activejob (= 5.2.1)
|
||||
activemodel (= 5.2.1)
|
||||
activerecord (= 5.2.1)
|
||||
activestorage (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.2.1)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-controller-testing (1.0.2)
|
||||
actionpack (~> 5.x, >= 5.0.1)
|
||||
actionview (~> 5.x, >= 5.0.1)
|
||||
activesupport (~> 5.x)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.0.4)
|
||||
loofah (~> 2.2, >= 2.2.2)
|
||||
railties (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.19.0, < 2.0)
|
||||
rake (12.3.1)
|
||||
rdoc (6.0.4)
|
||||
responders (2.4.0)
|
||||
actionpack (>= 4.2.0, < 5.3)
|
||||
railties (>= 4.2.0, < 5.3)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
test_after_commit (1.1.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.20.0)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.9.1)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.7)
|
||||
rack (>= 1.0)
|
||||
webrat (0.7.3)
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
websocket-driver (0.7.0)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activemodel-serializers-xml!
|
||||
devise!
|
||||
mocha (~> 1.1)
|
||||
omniauth
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails (~> 5.2)
|
||||
rails-controller-testing
|
||||
rdoc
|
||||
responders (~> 2.1)
|
||||
sqlite3 (~> 1.3.6)
|
||||
test_after_commit
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.1
|
||||
27
gemfiles/Gemfile.rails-6.0-stable
Normal file
27
gemfiles/Gemfile.rails-6.0-stable
Normal file
@@ -0,0 +1,27 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: ".."
|
||||
|
||||
gem "rails", '~> 6.0.0'
|
||||
gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc"
|
||||
|
||||
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
|
||||
|
||||
gem "rails-controller-testing"
|
||||
|
||||
gem "responders", "~> 3.0"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3", "~> 1.4"
|
||||
end
|
||||
219
gemfiles/Gemfile.rails-6.0-stable.lock
Normal file
219
gemfiles/Gemfile.rails-6.0-stable.lock
Normal file
@@ -0,0 +1,219 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/activemodel-serializers-xml.git
|
||||
revision: 93689638c28525acc65afb638fce866826532641
|
||||
specs:
|
||||
activemodel-serializers-xml (1.0.2)
|
||||
activemodel (>= 5.0.0.a)
|
||||
activesupport (>= 5.0.0.a)
|
||||
builder (~> 3.1)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.7.0)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailbox (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
activejob (= 6.0.0)
|
||||
activerecord (= 6.0.0)
|
||||
activestorage (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
mail (>= 2.7.1)
|
||||
actionmailer (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
actionview (= 6.0.0)
|
||||
activejob (= 6.0.0)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (6.0.0)
|
||||
actionview (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
rack (~> 2.0)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
||||
actiontext (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
activerecord (= 6.0.0)
|
||||
activestorage (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
nokogiri (>= 1.8.5)
|
||||
actionview (6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||
activejob (6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
activerecord (6.0.0)
|
||||
activemodel (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
activestorage (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
activejob (= 6.0.0)
|
||||
activerecord (= 6.0.0)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (6.0.0)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
zeitwerk (~> 2.1, >= 2.1.8)
|
||||
bcrypt (3.1.13)
|
||||
builder (3.2.3)
|
||||
concurrent-ruby (1.1.5)
|
||||
crass (1.0.4)
|
||||
erubi (1.8.0)
|
||||
faraday (0.15.4)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
hashie (3.6.0)
|
||||
i18n (1.6.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jwt (2.2.1)
|
||||
loofah (2.2.3)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.3)
|
||||
mimemagic (~> 0.3.2)
|
||||
metaclass (0.0.4)
|
||||
method_source (0.9.2)
|
||||
mimemagic (0.3.3)
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.11.3)
|
||||
mocha (1.9.0)
|
||||
metaclass (~> 0.0.1)
|
||||
multi_json (1.13.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
nio4r (2.4.0)
|
||||
nokogiri (1.10.4)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.4.1)
|
||||
faraday (>= 0.8, < 0.16.0)
|
||||
jwt (>= 1.0, < 3.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.9.0)
|
||||
hashie (>= 3.4.6, < 3.7.0)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (5.0.0)
|
||||
omniauth-oauth2 (~> 1.2)
|
||||
omniauth-oauth2 (1.6.0)
|
||||
oauth2 (~> 1.1)
|
||||
omniauth (~> 1.9)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
orm_adapter (0.5.0)
|
||||
rack (2.0.7)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (6.0.0)
|
||||
actioncable (= 6.0.0)
|
||||
actionmailbox (= 6.0.0)
|
||||
actionmailer (= 6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
actiontext (= 6.0.0)
|
||||
actionview (= 6.0.0)
|
||||
activejob (= 6.0.0)
|
||||
activemodel (= 6.0.0)
|
||||
activerecord (= 6.0.0)
|
||||
activestorage (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 6.0.0)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-controller-testing (1.0.4)
|
||||
actionpack (>= 5.0.1.x)
|
||||
actionview (>= 5.0.1.x)
|
||||
activesupport (>= 5.0.1.x)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.2.0)
|
||||
loofah (~> 2.2, >= 2.2.2)
|
||||
railties (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.20.3, < 2.0)
|
||||
rake (12.3.3)
|
||||
rdoc (6.1.1)
|
||||
responders (3.0.0)
|
||||
actionpack (>= 5.0)
|
||||
railties (>= 5.0)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.4.1)
|
||||
test_after_commit (1.1.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.20.3)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.9.1)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.8)
|
||||
rack (>= 2.0.6)
|
||||
webrat (0.7.3)
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
websocket-driver (0.7.1)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.4)
|
||||
zeitwerk (2.1.9)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activemodel-serializers-xml!
|
||||
devise!
|
||||
mocha (~> 1.1)
|
||||
omniauth
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails (~> 6.0.0)
|
||||
rails-controller-testing
|
||||
rdoc
|
||||
responders (~> 3.0)
|
||||
sqlite3 (~> 1.4)
|
||||
test_after_commit
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.2
|
||||
106
guides/bug_report_templates/integration_test.rb
Normal file
106
guides/bug_report_templates/integration_test.rb
Normal file
@@ -0,0 +1,106 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
begin
|
||||
require 'bundler/inline'
|
||||
rescue LoadError => e
|
||||
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
|
||||
raise e
|
||||
end
|
||||
|
||||
gemfile(true) do
|
||||
source 'https://rubygems.org'
|
||||
# Activate the gem you are reporting the issue against.
|
||||
gem 'rails', '~> 4.2.0'
|
||||
gem 'devise', '~> 4.0'
|
||||
gem 'sqlite3'
|
||||
gem 'byebug'
|
||||
end
|
||||
|
||||
require 'rack/test'
|
||||
require 'action_controller/railtie'
|
||||
require 'active_record'
|
||||
require 'devise/rails/routes'
|
||||
require 'devise/rails/warden_compat'
|
||||
|
||||
ActiveRecord::Base.establish_connection( adapter: :sqlite3, database: ':memory:')
|
||||
|
||||
class DeviseCreateUsers < ActiveRecord::Migration
|
||||
def change
|
||||
create_table(:users) do |t|
|
||||
t.string :email, null: false
|
||||
t.string :encrypted_password, null: true
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Devise.setup do |config|
|
||||
require 'devise/orm/active_record'
|
||||
config.secret_key = 'secret_key_base'
|
||||
end
|
||||
|
||||
class TestApp < Rails::Application
|
||||
config.root = File.dirname(__FILE__)
|
||||
config.session_store :cookie_store, key: 'cookie_store_key'
|
||||
secrets.secret_token = 'secret_token'
|
||||
secrets.secret_key_base = 'secret_key_base'
|
||||
config.eager_load = false
|
||||
|
||||
config.middleware.use Warden::Manager do |config|
|
||||
Devise.warden_config = config
|
||||
end
|
||||
|
||||
config.logger = Logger.new($stdout)
|
||||
Rails.logger = config.logger
|
||||
|
||||
end
|
||||
|
||||
Rails.application.initialize!
|
||||
|
||||
DeviseCreateUsers.migrate(:up)
|
||||
|
||||
class User < ActiveRecord::Base
|
||||
devise :database_authenticatable
|
||||
end
|
||||
|
||||
Rails.application.routes.draw do
|
||||
devise_for :users
|
||||
|
||||
get '/' => 'test#index'
|
||||
end
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
class TestController < ApplicationController
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
before_action :authenticate_user!
|
||||
|
||||
def index
|
||||
render plain: 'Home'
|
||||
end
|
||||
end
|
||||
|
||||
require 'minitest/autorun'
|
||||
|
||||
class BugTest < ActionDispatch::IntegrationTest
|
||||
include Rack::Test::Methods
|
||||
include Warden::Test::Helpers
|
||||
|
||||
def test_returns_success
|
||||
Warden.test_mode!
|
||||
|
||||
login_as User.create!(email: 'test@test.com', password: 'test123456', password_confirmation: 'test123456')
|
||||
|
||||
get '/'
|
||||
assert last_response.ok?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def app
|
||||
Rails.application
|
||||
end
|
||||
end
|
||||
195
lib/devise.rb
195
lib/devise.rb
@@ -1,26 +1,36 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails'
|
||||
require 'active_support/core_ext/numeric/time'
|
||||
require 'active_support/dependencies'
|
||||
require 'orm_adapter'
|
||||
require 'set'
|
||||
require 'securerandom'
|
||||
require 'responders'
|
||||
|
||||
module Devise
|
||||
autoload :Delegator, 'devise/delegator'
|
||||
autoload :Encryptor, 'devise/encryptor'
|
||||
autoload :FailureApp, 'devise/failure_app'
|
||||
autoload :OmniAuth, 'devise/omniauth'
|
||||
autoload :ParameterFilter, 'devise/parameter_filter'
|
||||
autoload :BaseSanitizer, 'devise/parameter_sanitizer'
|
||||
autoload :ParameterSanitizer, 'devise/parameter_sanitizer'
|
||||
autoload :TestHelpers, 'devise/test_helpers'
|
||||
autoload :TimeInflector, 'devise/time_inflector'
|
||||
autoload :TokenGenerator, 'devise/token_generator'
|
||||
autoload :SecretKeyFinder, 'devise/secret_key_finder'
|
||||
|
||||
module Controllers
|
||||
autoload :Helpers, 'devise/controllers/helpers'
|
||||
autoload :Rememberable, 'devise/controllers/rememberable'
|
||||
autoload :ScopedViews, 'devise/controllers/scoped_views'
|
||||
autoload :UrlHelpers, 'devise/controllers/url_helpers'
|
||||
autoload :Helpers, 'devise/controllers/helpers'
|
||||
autoload :Rememberable, 'devise/controllers/rememberable'
|
||||
autoload :ScopedViews, 'devise/controllers/scoped_views'
|
||||
autoload :SignInOut, 'devise/controllers/sign_in_out'
|
||||
autoload :StoreLocation, 'devise/controllers/store_location'
|
||||
autoload :UrlHelpers, 'devise/controllers/url_helpers'
|
||||
end
|
||||
|
||||
module Hooks
|
||||
autoload :Proxy, 'devise/hooks/proxy'
|
||||
end
|
||||
|
||||
module Mailers
|
||||
@@ -28,17 +38,22 @@ module Devise
|
||||
end
|
||||
|
||||
module Strategies
|
||||
autoload :Base, 'devise/strategies/base'
|
||||
autoload :Base, 'devise/strategies/base'
|
||||
autoload :Authenticatable, 'devise/strategies/authenticatable'
|
||||
end
|
||||
|
||||
module Test
|
||||
autoload :ControllerHelpers, 'devise/test/controller_helpers'
|
||||
autoload :IntegrationHelpers, 'devise/test/integration_helpers'
|
||||
end
|
||||
|
||||
# Constants which holds devise configuration for extensions. Those should
|
||||
# not be modified by the "end user" (this is why they are constants).
|
||||
ALL = []
|
||||
CONTROLLERS = ActiveSupport::OrderedHash.new
|
||||
ROUTES = ActiveSupport::OrderedHash.new
|
||||
STRATEGIES = ActiveSupport::OrderedHash.new
|
||||
URL_HELPERS = ActiveSupport::OrderedHash.new
|
||||
CONTROLLERS = {}
|
||||
ROUTES = {}
|
||||
STRATEGIES = {}
|
||||
URL_HELPERS = {}
|
||||
|
||||
# Strategies that do not require user input.
|
||||
NO_INPUT = []
|
||||
@@ -50,23 +65,13 @@ module Devise
|
||||
mattr_accessor :secret_key
|
||||
@@secret_key = nil
|
||||
|
||||
# Allow insecure token lookup. Must be used
|
||||
# temporarily just for migration.
|
||||
mattr_accessor :allow_insecure_token_lookup
|
||||
@@allow_insecure_tokens_lookup = false
|
||||
|
||||
# Allow insecure sign in after confirmation. Must be used
|
||||
# temporarily just for migration.
|
||||
mattr_accessor :allow_insecure_sign_in_after_confirmation
|
||||
@@allow_insecure_sign_in_after_confirmation = false
|
||||
|
||||
# Custom domain or key for cookies. Not set by default
|
||||
mattr_accessor :rememberable_options
|
||||
@@rememberable_options = {}
|
||||
|
||||
# The number of times to encrypt password.
|
||||
# The number of times to hash the password.
|
||||
mattr_accessor :stretches
|
||||
@@stretches = 10
|
||||
@@stretches = 11
|
||||
|
||||
# The default key used when authenticating over http auth.
|
||||
mattr_accessor :http_authentication_key
|
||||
@@ -74,7 +79,7 @@ module Devise
|
||||
|
||||
# Keys used when authenticating a user.
|
||||
mattr_accessor :authentication_keys
|
||||
@@authentication_keys = [ :email ]
|
||||
@@authentication_keys = [:email]
|
||||
|
||||
# Request keys used when authenticating a user.
|
||||
mattr_accessor :request_keys
|
||||
@@ -82,11 +87,11 @@ module Devise
|
||||
|
||||
# Keys that should be case-insensitive.
|
||||
mattr_accessor :case_insensitive_keys
|
||||
@@case_insensitive_keys = [ :email ]
|
||||
@@case_insensitive_keys = [:email]
|
||||
|
||||
# Keys that should have whitespace stripped.
|
||||
mattr_accessor :strip_whitespace_keys
|
||||
@@strip_whitespace_keys = []
|
||||
@@strip_whitespace_keys = [:email]
|
||||
|
||||
# If http authentication is enabled by default.
|
||||
mattr_accessor :http_authenticatable
|
||||
@@ -104,11 +109,11 @@ module Devise
|
||||
mattr_accessor :http_authentication_realm
|
||||
@@http_authentication_realm = "Application"
|
||||
|
||||
# Email regex used to validate email formats. It simply asserts that
|
||||
# an one (and only one) @ exists in the given string. This is mainly
|
||||
# to give user feedback and not to assert the e-mail validity.
|
||||
# Email regex used to validate email formats. It asserts that there are no
|
||||
# @ symbols or whitespaces in either the localpart or the domain, and that
|
||||
# there is a single @ symbol separating the localpart and the domain.
|
||||
mattr_accessor :email_regexp
|
||||
@@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
|
||||
@@email_regexp = /\A[^@\s]+@[^@\s]+\z/
|
||||
|
||||
# Range validation for password length
|
||||
mattr_accessor :password_length
|
||||
@@ -122,6 +127,10 @@ module Devise
|
||||
mattr_accessor :extend_remember_period
|
||||
@@extend_remember_period = false
|
||||
|
||||
# If true, all the remember me tokens are going to be invalidated when the user signs out.
|
||||
mattr_accessor :expire_all_remember_me_on_sign_out
|
||||
@@expire_all_remember_me_on_sign_out = true
|
||||
|
||||
# Time interval you can access your account before confirming your account.
|
||||
# nil - allows unconfirmed access for unlimited time
|
||||
mattr_accessor :allow_unconfirmed_access_for
|
||||
@@ -133,25 +142,28 @@ module Devise
|
||||
|
||||
# Defines which key will be used when confirming an account.
|
||||
mattr_accessor :confirmation_keys
|
||||
@@confirmation_keys = [ :email ]
|
||||
@@confirmation_keys = [:email]
|
||||
|
||||
# Defines if email should be reconfirmable.
|
||||
# False by default for backwards compatibility.
|
||||
mattr_accessor :reconfirmable
|
||||
@@reconfirmable = false
|
||||
@@reconfirmable = true
|
||||
|
||||
# Time interval to timeout the user session without activity.
|
||||
mattr_accessor :timeout_in
|
||||
@@timeout_in = 30.minutes
|
||||
|
||||
# Authentication token expiration on timeout
|
||||
mattr_accessor :expire_auth_token_on_timeout
|
||||
@@expire_auth_token_on_timeout = false
|
||||
|
||||
# Used to encrypt password. Please generate one with rake secret.
|
||||
# Used to hash the password. Please generate one with rails secret.
|
||||
mattr_accessor :pepper
|
||||
@@pepper = nil
|
||||
|
||||
# Used to send notification to the original user email when their email is changed.
|
||||
mattr_accessor :send_email_changed_notification
|
||||
@@send_email_changed_notification = false
|
||||
|
||||
# Used to enable sending notification to user when their password is changed.
|
||||
mattr_accessor :send_password_change_notification
|
||||
@@send_password_change_notification = false
|
||||
|
||||
# Scoped views. Since it relies on fallbacks to render default views, it's
|
||||
# turned off by default.
|
||||
mattr_accessor :scoped_views
|
||||
@@ -164,7 +176,7 @@ module Devise
|
||||
|
||||
# Defines which key will be used when locking and unlocking an account
|
||||
mattr_accessor :unlock_keys
|
||||
@@unlock_keys = [ :email ]
|
||||
@@unlock_keys = [:email]
|
||||
|
||||
# Defines which strategy can be used to unlock an account.
|
||||
# Values: :email, :time, :both
|
||||
@@ -181,12 +193,16 @@ module Devise
|
||||
|
||||
# Defines which key will be used when recovering the password for an account
|
||||
mattr_accessor :reset_password_keys
|
||||
@@reset_password_keys = [ :email ]
|
||||
@@reset_password_keys = [:email]
|
||||
|
||||
# Time interval you can reset your password with a reset password key
|
||||
mattr_accessor :reset_password_within
|
||||
@@reset_password_within = 6.hours
|
||||
|
||||
# When set to false, resetting a password does not automatically sign in a user
|
||||
mattr_accessor :sign_in_after_reset_password
|
||||
@@sign_in_after_reset_password = true
|
||||
|
||||
# The default scope which is used by warden.
|
||||
mattr_accessor :default_scope
|
||||
@@default_scope = nil
|
||||
@@ -195,13 +211,9 @@ module Devise
|
||||
mattr_accessor :mailer_sender
|
||||
@@mailer_sender = nil
|
||||
|
||||
# Authentication token params key name of choice. E.g. /users/sign_in?some_key=...
|
||||
mattr_accessor :token_authentication_key
|
||||
@@token_authentication_key = :auth_token
|
||||
|
||||
# Skip session storage for the following strategies
|
||||
mattr_accessor :skip_session_storage
|
||||
@@skip_session_storage = []
|
||||
@@skip_session_storage = [:http_auth]
|
||||
|
||||
# Which formats should be treated as navigational.
|
||||
mattr_accessor :navigational_formats
|
||||
@@ -213,7 +225,7 @@ module Devise
|
||||
|
||||
# The default method used while signing out
|
||||
mattr_accessor :sign_out_via
|
||||
@@sign_out_via = :get
|
||||
@@sign_out_via = :delete
|
||||
|
||||
# The parent controller all Devise controllers inherits from.
|
||||
# Defaults to ApplicationController. This should be set early
|
||||
@@ -228,12 +240,12 @@ module Devise
|
||||
@@parent_mailer = "ActionMailer::Base"
|
||||
|
||||
# The router Devise should use to generate routes. Defaults
|
||||
# to :main_app. Should be overriden by engines in order
|
||||
# to :main_app. Should be overridden by engines in order
|
||||
# to provide custom routes.
|
||||
mattr_accessor :router_name
|
||||
@@router_name = nil
|
||||
|
||||
# Set the omniauth path prefix so it can be overriden when
|
||||
# Set the OmniAuth path prefix so it can be overridden when
|
||||
# Devise is used in a mountable engine
|
||||
mattr_accessor :omniauth_path_prefix
|
||||
@@omniauth_path_prefix = nil
|
||||
@@ -242,15 +254,22 @@ module Devise
|
||||
mattr_accessor :clean_up_csrf_token_on_authentication
|
||||
@@clean_up_csrf_token_on_authentication = true
|
||||
|
||||
# When false, Devise will not attempt to reload routes on eager load.
|
||||
# This can reduce the time taken to boot the app but if your application
|
||||
# requires the Devise mappings to be loaded during boot time the application
|
||||
# won't boot properly.
|
||||
mattr_accessor :reload_routes
|
||||
@@reload_routes = true
|
||||
|
||||
# PRIVATE CONFIGURATION
|
||||
|
||||
# Store scopes mappings.
|
||||
mattr_reader :mappings
|
||||
@@mappings = ActiveSupport::OrderedHash.new
|
||||
@@mappings = {}
|
||||
|
||||
# Omniauth configurations.
|
||||
# OmniAuth configurations.
|
||||
mattr_reader :omniauth_configs
|
||||
@@omniauth_configs = ActiveSupport::OrderedHash.new
|
||||
@@omniauth_configs = {}
|
||||
|
||||
# Define a set of modules that are called when a mapping is added.
|
||||
mattr_reader :helpers
|
||||
@@ -260,24 +279,40 @@ module Devise
|
||||
# Private methods to interface with Warden.
|
||||
mattr_accessor :warden_config
|
||||
@@warden_config = nil
|
||||
@@warden_config_block = nil
|
||||
@@warden_config_blocks = []
|
||||
|
||||
# When true, enter in paranoid mode to avoid user enumeration.
|
||||
mattr_accessor :paranoid
|
||||
@@paranoid = false
|
||||
|
||||
# When true, warn user if they just used next-to-last attempt of authentication
|
||||
mattr_accessor :last_attempt_warning
|
||||
@@last_attempt_warning = true
|
||||
|
||||
# Stores the token generator
|
||||
mattr_accessor :token_generator
|
||||
@@token_generator = nil
|
||||
|
||||
# Default way to setup Devise. Run rails generate devise_install to create
|
||||
# When set to false, changing a password does not automatically sign in a user
|
||||
mattr_accessor :sign_in_after_change_password
|
||||
@@sign_in_after_change_password = true
|
||||
|
||||
def self.rails51? # :nodoc:
|
||||
Rails.gem_version >= Gem::Version.new("5.1.x")
|
||||
end
|
||||
|
||||
def self.activerecord51? # :nodoc:
|
||||
defined?(ActiveRecord) && ActiveRecord.gem_version >= Gem::Version.new("5.1.x")
|
||||
end
|
||||
|
||||
# Default way to set up Devise. Run rails generate devise_install to create
|
||||
# a fresh initializer with all configuration values.
|
||||
def self.setup
|
||||
yield self
|
||||
end
|
||||
|
||||
class Getter
|
||||
def initialize name
|
||||
def initialize(name)
|
||||
@name = name
|
||||
end
|
||||
|
||||
@@ -287,12 +322,8 @@ module Devise
|
||||
end
|
||||
|
||||
def self.ref(arg)
|
||||
if defined?(ActiveSupport::Dependencies::ClassCache)
|
||||
ActiveSupport::Dependencies::reference(arg)
|
||||
Getter.new(arg)
|
||||
else
|
||||
ActiveSupport::Dependencies.ref(arg)
|
||||
end
|
||||
ActiveSupport::Dependencies.reference(arg)
|
||||
Getter.new(arg)
|
||||
end
|
||||
|
||||
def self.available_router_name
|
||||
@@ -323,7 +354,12 @@ module Devise
|
||||
mapping
|
||||
end
|
||||
|
||||
# Make Devise aware of an 3rd party Devise-module (like invitable). For convenience.
|
||||
# Register available devise modules. For the standard modules that Devise provides, this method is
|
||||
# called from lib/devise/modules.rb. Third-party modules need to be added explicitly using this method.
|
||||
#
|
||||
# Note that adding a module using this method does not cause it to be used in the authentication
|
||||
# process. That requires that the module be listed in the arguments passed to the 'devise' method
|
||||
# in the model class definition.
|
||||
#
|
||||
# == Options:
|
||||
#
|
||||
@@ -331,6 +367,7 @@ module Devise
|
||||
# +controller+ - Symbol representing the name of an existing or custom *controller* for this module.
|
||||
# +route+ - Symbol representing the named *route* helper for this module.
|
||||
# +strategy+ - Symbol representing if this module got a custom *strategy*.
|
||||
# +insert_at+ - Integer representing the order in which this module's model will be included
|
||||
#
|
||||
# All values, except :model, accept also a boolean and will have the same name as the given module
|
||||
# name.
|
||||
@@ -338,12 +375,14 @@ module Devise
|
||||
# == Examples:
|
||||
#
|
||||
# Devise.add_module(:party_module)
|
||||
# Devise.add_module(:party_module, :strategy => true, :controller => :sessions)
|
||||
# Devise.add_module(:party_module, :model => 'party_module/model')
|
||||
# Devise.add_module(:party_module, strategy: true, controller: :sessions)
|
||||
# Devise.add_module(:party_module, model: 'party_module/model')
|
||||
# Devise.add_module(:party_module, insert_at: 0)
|
||||
#
|
||||
def self.add_module(module_name, options = {})
|
||||
ALL << module_name
|
||||
options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input)
|
||||
options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input, :insert_at)
|
||||
|
||||
ALL.insert (options[:insert_at] || -1), module_name
|
||||
|
||||
if strategy = options[:strategy]
|
||||
strategy = (strategy == true ? module_name : strategy)
|
||||
@@ -388,7 +427,7 @@ module Devise
|
||||
# Sets warden configuration using a block that will be invoked on warden
|
||||
# initialization.
|
||||
#
|
||||
# Devise.initialize do |config|
|
||||
# Devise.setup do |config|
|
||||
# config.allow_unconfirmed_access_for = 2.days
|
||||
#
|
||||
# config.warden do |manager|
|
||||
@@ -397,15 +436,14 @@ module Devise
|
||||
# end
|
||||
# end
|
||||
def self.warden(&block)
|
||||
@@warden_config_block = block
|
||||
@@warden_config_blocks << block
|
||||
end
|
||||
|
||||
# Specify an omniauth provider.
|
||||
# Specify an OmniAuth provider.
|
||||
#
|
||||
# config.omniauth :github, APP_ID, APP_SECRET
|
||||
#
|
||||
def self.omniauth(provider, *args)
|
||||
@@helpers << Devise::OmniAuth::UrlHelpers
|
||||
config = Devise::OmniAuth::Config.new(provider, args)
|
||||
@@omniauth_configs[config.strategy_name.to_sym] = config
|
||||
end
|
||||
@@ -428,8 +466,8 @@ module Devise
|
||||
Devise::Controllers::UrlHelpers.generate_helpers!
|
||||
end
|
||||
|
||||
# A method used internally to setup warden manager from the Rails initialize
|
||||
# block.
|
||||
# A method used internally to complete the setup of warden manager after routes are loaded.
|
||||
# See lib/devise/rails/routes.rb - ActionDispatch::Routing::RouteSet#finalize_with_devise!
|
||||
def self.configure_warden! #:nodoc:
|
||||
@@warden_configured ||= begin
|
||||
warden_config.failure_app = Devise::Delegator.new
|
||||
@@ -437,28 +475,29 @@ module Devise
|
||||
warden_config.intercept_401 = false
|
||||
|
||||
Devise.mappings.each_value do |mapping|
|
||||
warden_config.scope_defaults mapping.name, :strategies => mapping.strategies
|
||||
warden_config.scope_defaults mapping.name, strategies: mapping.strategies
|
||||
|
||||
warden_config.serialize_into_session(mapping.name) do |record|
|
||||
mapping.to.serialize_into_session(record)
|
||||
end
|
||||
|
||||
warden_config.serialize_from_session(mapping.name) do |key|
|
||||
# Previous versions contained an additional entry at the beginning of
|
||||
# key with the record's class name.
|
||||
args = key[-2, 2]
|
||||
warden_config.serialize_from_session(mapping.name) do |args|
|
||||
mapping.to.serialize_from_session(*args)
|
||||
end
|
||||
end
|
||||
|
||||
@@warden_config_block.try :call, Devise.warden_config
|
||||
@@warden_config_blocks.map { |block| block.call Devise.warden_config }
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
# Generate a friendly string randomly to be used as token.
|
||||
def self.friendly_token
|
||||
SecureRandom.urlsafe_base64(15).tr('lIO0', 'sxyz')
|
||||
# By default, length is 20 characters.
|
||||
def self.friendly_token(length = 20)
|
||||
# To calculate real characters, we must perform this operation.
|
||||
# See SecureRandom.urlsafe_base64
|
||||
rlength = (length * 3) / 4
|
||||
SecureRandom.urlsafe_base64(rlength).tr('lIO0', 'sxyz')
|
||||
end
|
||||
|
||||
# constant-time comparison algorithm to prevent timing attacks
|
||||
|
||||
@@ -1,14 +1,84 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Controllers
|
||||
# Those helpers are convenience methods added to ApplicationController.
|
||||
module Helpers
|
||||
extend ActiveSupport::Concern
|
||||
include Devise::Controllers::SignInOut
|
||||
include Devise::Controllers::StoreLocation
|
||||
|
||||
included do
|
||||
helper_method :warden, :signed_in?, :devise_controller?
|
||||
if respond_to?(:helper_method)
|
||||
helper_method :warden, :signed_in?, :devise_controller?
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
# Define authentication filters and accessor helpers for a group of mappings.
|
||||
# These methods are useful when you are working with multiple mappings that
|
||||
# share some functionality. They are pretty much the same as the ones
|
||||
# defined for normal mappings.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# inside BlogsController (or any other controller, it doesn't matter which):
|
||||
# devise_group :blogger, contains: [:user, :admin]
|
||||
#
|
||||
# Generated methods:
|
||||
# authenticate_blogger! # Redirects unless user or admin are signed in
|
||||
# blogger_signed_in? # Checks whether there is either a user or an admin signed in
|
||||
# current_blogger # Currently signed in user or admin
|
||||
# current_bloggers # Currently signed in user and admin
|
||||
#
|
||||
# Use:
|
||||
# before_action :authenticate_blogger! # Redirects unless either a user or an admin are authenticated
|
||||
# before_action ->{ authenticate_blogger! :admin } # Redirects to the admin login page
|
||||
# current_blogger :user # Preferably returns a User if one is signed in
|
||||
#
|
||||
def devise_group(group_name, opts={})
|
||||
mappings = "[#{ opts[:contains].map { |m| ":#{m}" }.join(',') }]"
|
||||
|
||||
class_eval <<-METHODS, __FILE__, __LINE__ + 1
|
||||
def authenticate_#{group_name}!(favourite=nil, opts={})
|
||||
unless #{group_name}_signed_in?
|
||||
mappings = #{mappings}
|
||||
mappings.unshift mappings.delete(favourite.to_sym) if favourite
|
||||
mappings.each do |mapping|
|
||||
opts[:scope] = mapping
|
||||
warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def #{group_name}_signed_in?
|
||||
#{mappings}.any? do |mapping|
|
||||
warden.authenticate?(scope: mapping)
|
||||
end
|
||||
end
|
||||
|
||||
def current_#{group_name}(favourite=nil)
|
||||
mappings = #{mappings}
|
||||
mappings.unshift mappings.delete(favourite.to_sym) if favourite
|
||||
mappings.each do |mapping|
|
||||
current = warden.authenticate(scope: mapping)
|
||||
return current if current
|
||||
end
|
||||
nil
|
||||
end
|
||||
|
||||
def current_#{group_name.to_s.pluralize}
|
||||
#{mappings}.map do |mapping|
|
||||
warden.authenticate(scope: mapping)
|
||||
end.compact
|
||||
end
|
||||
|
||||
if respond_to?(:helper_method)
|
||||
helper_method "current_#{group_name}", "current_#{group_name.to_s.pluralize}", "#{group_name}_signed_in?"
|
||||
end
|
||||
METHODS
|
||||
end
|
||||
|
||||
def log_process_action(payload)
|
||||
payload[:status] ||= 401 unless payload[:exception]
|
||||
super
|
||||
@@ -16,7 +86,7 @@ module Devise
|
||||
end
|
||||
|
||||
# Define authentication filters and accessor helpers based on mappings.
|
||||
# These filters should be used inside the controllers as before_filters,
|
||||
# These filters should be used inside the controllers as before_actions,
|
||||
# so you can control the scope of the user who should be signed in to
|
||||
# access that specific controller/action.
|
||||
# Example:
|
||||
@@ -36,8 +106,8 @@ module Devise
|
||||
# admin_session # Session data available only to the admin scope
|
||||
#
|
||||
# Use:
|
||||
# before_filter :authenticate_user! # Tell devise to use :user map
|
||||
# before_filter :authenticate_admin! # Tell devise to use :admin map
|
||||
# before_action :authenticate_user! # Tell devise to use :user map
|
||||
# before_action :authenticate_admin! # Tell devise to use :admin map
|
||||
#
|
||||
def self.define_helpers(mapping) #:nodoc:
|
||||
mapping = mapping.name
|
||||
@@ -53,7 +123,7 @@ module Devise
|
||||
end
|
||||
|
||||
def current_#{mapping}
|
||||
@current_#{mapping} ||= warden.authenticate(:scope => :#{mapping})
|
||||
@current_#{mapping} ||= warden.authenticate(scope: :#{mapping})
|
||||
end
|
||||
|
||||
def #{mapping}_session
|
||||
@@ -62,33 +132,31 @@ module Devise
|
||||
METHODS
|
||||
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
helper_method "current_#{mapping}", "#{mapping}_signed_in?", "#{mapping}_session"
|
||||
if respond_to?(:helper_method)
|
||||
helper_method "current_#{mapping}", "#{mapping}_signed_in?", "#{mapping}_session"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# The main accessor for the warden proxy instance
|
||||
def warden
|
||||
request.env['warden']
|
||||
request.env['warden'] or raise MissingWarden
|
||||
end
|
||||
|
||||
# Return true if it's a devise_controller. false to all controllers unless
|
||||
# the controllers defined inside devise. Useful if you want to apply a before
|
||||
# filter to all controllers, except the ones in devise:
|
||||
#
|
||||
# before_filter :my_filter, :unless => :devise_controller?
|
||||
# before_action :my_filter, unless: :devise_controller?
|
||||
def devise_controller?
|
||||
is_a?(DeviseController)
|
||||
is_a?(::DeviseController)
|
||||
end
|
||||
|
||||
# Setup a param sanitizer to filter parameters using strong_parameters. See
|
||||
# Set up a param sanitizer to filter parameters using strong_parameters. See
|
||||
# lib/devise/parameter_sanitizer.rb for more info. Override this
|
||||
# method in your application controller to use your own parameter sanitizer.
|
||||
def devise_parameter_sanitizer
|
||||
@devise_parameter_sanitizer ||= if defined?(ActionController::StrongParameters)
|
||||
Devise::ParameterSanitizer.new(resource_class, resource_name, params)
|
||||
else
|
||||
Devise::BaseSanitizer.new(resource_class, resource_name, params)
|
||||
end
|
||||
@devise_parameter_sanitizer ||= Devise::ParameterSanitizer.new(resource_class, resource_name, params)
|
||||
end
|
||||
|
||||
# Tell warden that params authentication is allowed for that specific page.
|
||||
@@ -96,108 +164,20 @@ module Devise
|
||||
request.env["devise.allow_params_authentication"] = true
|
||||
end
|
||||
|
||||
# Return true if the given scope is signed in session. If no scope given, return
|
||||
# true if any scope is signed in. Does not run authentication hooks.
|
||||
def signed_in?(scope=nil)
|
||||
[ scope || Devise.mappings.keys ].flatten.any? do |_scope|
|
||||
warden.authenticate?(:scope => _scope)
|
||||
end
|
||||
end
|
||||
|
||||
# Sign in a user that already was authenticated. This helper is useful for logging
|
||||
# users in after sign up.
|
||||
#
|
||||
# All options given to sign_in is passed forward to the set_user method in warden.
|
||||
# The only exception is the :bypass option, which bypass warden callbacks and stores
|
||||
# the user straight in session. This option is useful in cases the user is already
|
||||
# signed in, but we want to refresh the credentials in session.
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# sign_in :user, @user # sign_in(scope, resource)
|
||||
# sign_in @user # sign_in(resource)
|
||||
# sign_in @user, :event => :authentication # sign_in(resource, options)
|
||||
# sign_in @user, :store => false # sign_in(resource, options)
|
||||
# sign_in @user, :bypass => true # sign_in(resource, options)
|
||||
#
|
||||
def sign_in(resource_or_scope, *args)
|
||||
options = args.extract_options!
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
resource = args.last || resource_or_scope
|
||||
|
||||
expire_session_data_after_sign_in!
|
||||
|
||||
if options[:bypass]
|
||||
warden.session_serializer.store(resource, scope)
|
||||
elsif warden.user(scope) == resource && !options.delete(:force)
|
||||
# Do nothing. User already signed in and we are not forcing it.
|
||||
true
|
||||
else
|
||||
warden.set_user(resource, options.merge!(:scope => scope))
|
||||
end
|
||||
end
|
||||
|
||||
# Sign out a given user or scope. This helper is useful for signing out a user
|
||||
# after deleting accounts. Returns true if there was a logout and false if there
|
||||
# is no user logged in on the referred scope
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# sign_out :user # sign_out(scope)
|
||||
# sign_out @user # sign_out(resource)
|
||||
#
|
||||
def sign_out(resource_or_scope=nil)
|
||||
return sign_out_all_scopes unless resource_or_scope
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
user = warden.user(:scope => scope, :run_callbacks => false) # If there is no user
|
||||
|
||||
warden.raw_session.inspect # Without this inspect here. The session does not clear.
|
||||
warden.logout(scope)
|
||||
warden.clear_strategies_cache!(:scope => scope)
|
||||
instance_variable_set(:"@current_#{scope}", nil)
|
||||
|
||||
!!user
|
||||
end
|
||||
|
||||
# Sign out all active users or scopes. This helper is useful for signing out all roles
|
||||
# in one click. This signs out ALL scopes in warden. Returns true if there was at least one logout
|
||||
# and false if there was no user logged in on all scopes.
|
||||
def sign_out_all_scopes(lock=true)
|
||||
users = Devise.mappings.keys.map { |s| warden.user(:scope => s, :run_callbacks => false) }
|
||||
|
||||
warden.raw_session.inspect
|
||||
warden.logout
|
||||
expire_devise_cached_variables!
|
||||
warden.clear_strategies_cache!
|
||||
warden.lock! if lock
|
||||
|
||||
users.any?
|
||||
end
|
||||
|
||||
# Returns and delete (if it's navigational format) the url stored in the session for
|
||||
# the given scope. Useful for giving redirect backs after sign up:
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# redirect_to stored_location_for(:user) || root_path
|
||||
#
|
||||
def stored_location_for(resource_or_scope)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
|
||||
if is_navigational_format?
|
||||
session.delete("#{scope}_return_to")
|
||||
else
|
||||
session["#{scope}_return_to"]
|
||||
end
|
||||
end
|
||||
|
||||
# The scope root url to be used when he's signed in. By default, it first
|
||||
# The scope root url to be used when they're signed in. By default, it first
|
||||
# tries to find a resource_root_path, otherwise it uses the root_path.
|
||||
def signed_in_root_path(resource_or_scope)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
router_name = Devise.mappings[scope].router_name
|
||||
|
||||
home_path = "#{scope}_root_path"
|
||||
if respond_to?(home_path, true)
|
||||
send(home_path)
|
||||
|
||||
context = router_name ? send(router_name) : self
|
||||
|
||||
if context.respond_to?(home_path, true)
|
||||
context.send(home_path)
|
||||
elsif context.respond_to?(:root_path)
|
||||
context.root_path
|
||||
elsif respond_to?(:root_path)
|
||||
root_path
|
||||
else
|
||||
@@ -214,10 +194,10 @@ module Devise
|
||||
# root path. For a user scope, you can define the default url in
|
||||
# the following way:
|
||||
#
|
||||
# map.user_root '/users', :controller => 'users' # creates user_root_path
|
||||
# get '/users' => 'users#index', as: :user_root # creates user_root_path
|
||||
#
|
||||
# map.namespace :user do |user|
|
||||
# user.root :controller => 'users' # creates user_root_path
|
||||
# namespace :user do
|
||||
# root 'users#index' # creates user_root_path
|
||||
# end
|
||||
#
|
||||
# If the resource root path is not defined, root_path is used. However,
|
||||
@@ -243,7 +223,10 @@ module Devise
|
||||
#
|
||||
# By default it is the root_path.
|
||||
def after_sign_out_path_for(resource_or_scope)
|
||||
respond_to?(:root_path) ? root_path : "/"
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
router_name = Devise.mappings[scope].router_name
|
||||
context = router_name ? send(router_name) : self
|
||||
context.respond_to?(:root_path) ? context.root_path : "/"
|
||||
end
|
||||
|
||||
# Sign in a user and tries to redirect first to the stored location and
|
||||
@@ -257,10 +240,6 @@ module Devise
|
||||
redirect_to after_sign_in_path_for(resource)
|
||||
end
|
||||
|
||||
def expire_session_data_after_sign_in!
|
||||
session.keys.grep(/^devise\./).each { |k| session.delete(k) }
|
||||
end
|
||||
|
||||
# Sign out a user and tries to redirect to the url specified by
|
||||
# after_sign_out_path_for.
|
||||
def sign_out_and_redirect(resource_or_scope)
|
||||
@@ -273,10 +252,9 @@ module Devise
|
||||
# Overwrite Rails' handle unverified request to sign out all scopes,
|
||||
# clear run strategies and remove cached variables.
|
||||
def handle_unverified_request
|
||||
sign_out_all_scopes(false)
|
||||
super # call the default behaviour which resets/nullifies/raises
|
||||
request.env["devise.skip_storage"] = true
|
||||
expire_devise_cached_variables!
|
||||
super # call the default behaviour which resets the session
|
||||
sign_out_all_scopes(false)
|
||||
end
|
||||
|
||||
def request_format
|
||||
@@ -287,11 +265,29 @@ module Devise
|
||||
Devise.navigational_formats.include?(request_format)
|
||||
end
|
||||
|
||||
# Check if flash messages should be emitted. Default is to do it on
|
||||
# navigational formats
|
||||
def is_flashing_format?
|
||||
request.respond_to?(:flash) && is_navigational_format?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def expire_devise_cached_variables!
|
||||
def expire_data_after_sign_out!
|
||||
Devise.mappings.each { |_,m| instance_variable_set("@current_#{m.name}", nil) }
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class MissingWarden < StandardError
|
||||
def initialize
|
||||
super "Devise could not find the `Warden::Proxy` instance on your request environment.\n" + \
|
||||
"Make sure that your application is loading Devise and Warden as expected and that " + \
|
||||
"the `Warden::Manager` middleware is present in your middleware stack.\n" + \
|
||||
"If you are seeing this on one of your tests, ensure that your tests are either " + \
|
||||
"executing the Rails middleware stack or that your tests are using the `Devise::Test::ControllerHelpers` " + \
|
||||
"module to inject the `request.env['warden']` object for you."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Controllers
|
||||
# A module that may be optionally included in a controller in order
|
||||
# to provide remember me behavior.
|
||||
# to provide remember me behavior. Useful when signing in is done
|
||||
# through a callback, like in OmniAuth.
|
||||
module Rememberable
|
||||
# Return default cookie values retrieved from session options.
|
||||
def self.cookie_values
|
||||
Rails.configuration.session_options.slice(:path, :domain, :secure)
|
||||
end
|
||||
|
||||
# A small warden proxy so we can remember and forget uses from hooks.
|
||||
class Proxy #:nodoc:
|
||||
include Devise::Controllers::Rememberable
|
||||
|
||||
delegate :cookies, :env, :to => :@warden
|
||||
|
||||
def initialize(warden)
|
||||
@warden = warden
|
||||
end
|
||||
def remember_me_is_active?(resource)
|
||||
return false unless resource.respond_to?(:remember_me)
|
||||
scope = Devise::Mapping.find_scope!(resource)
|
||||
_, token, generated_at = cookies.signed[remember_key(resource, scope)]
|
||||
resource.remember_me?(token, generated_at)
|
||||
end
|
||||
|
||||
# Remembers the given resource by setting up a cookie
|
||||
def remember_me(resource)
|
||||
return if env["devise.skip_storage"]
|
||||
return if request.env["devise.skip_storage"]
|
||||
scope = Devise::Mapping.find_scope!(resource)
|
||||
resource.remember_me!(resource.extend_remember_period)
|
||||
resource.remember_me!
|
||||
cookies.signed[remember_key(resource, scope)] = remember_cookie_values(resource)
|
||||
end
|
||||
|
||||
@@ -41,11 +40,11 @@ module Devise
|
||||
end
|
||||
|
||||
def remember_cookie_values(resource)
|
||||
options = { :httponly => true }
|
||||
options = { httponly: true }
|
||||
options.merge!(forget_cookie_values(resource))
|
||||
options.merge!(
|
||||
:value => resource.class.serialize_into_cookie(resource),
|
||||
:expires => resource.remember_expires_at
|
||||
value: resource.class.serialize_into_cookie(resource),
|
||||
expires: resource.remember_expires_at
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Controllers
|
||||
module ScopedViews
|
||||
@@ -14,4 +16,4 @@ module Devise
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
119
lib/devise/controllers/sign_in_out.rb
Normal file
119
lib/devise/controllers/sign_in_out.rb
Normal file
@@ -0,0 +1,119 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Controllers
|
||||
# Provide sign in and sign out functionality.
|
||||
# Included by default in all controllers.
|
||||
module SignInOut
|
||||
# Return true if the given scope is signed in session. If no scope given, return
|
||||
# true if any scope is signed in. This will run authentication hooks, which may
|
||||
# cause exceptions to be thrown from this method; if you simply want to check
|
||||
# if a scope has already previously been authenticated without running
|
||||
# authentication hooks, you can directly call `warden.authenticated?(scope: scope)`
|
||||
def signed_in?(scope=nil)
|
||||
[scope || Devise.mappings.keys].flatten.any? do |_scope|
|
||||
warden.authenticate?(scope: _scope)
|
||||
end
|
||||
end
|
||||
|
||||
# Sign in a user that already was authenticated. This helper is useful for logging
|
||||
# users in after sign up. All options given to sign_in is passed forward
|
||||
# to the set_user method in warden.
|
||||
# If you are using a custom warden strategy and the timeoutable module, you have to
|
||||
# set `env["devise.skip_timeout"] = true` in the request to use this method, like we do
|
||||
# in the sessions controller: https://github.com/plataformatec/devise/blob/master/app/controllers/devise/sessions_controller.rb#L7
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# sign_in :user, @user # sign_in(scope, resource)
|
||||
# sign_in @user # sign_in(resource)
|
||||
# sign_in @user, event: :authentication # sign_in(resource, options)
|
||||
# sign_in @user, store: false # sign_in(resource, options)
|
||||
#
|
||||
def sign_in(resource_or_scope, *args)
|
||||
options = args.extract_options!
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
resource = args.last || resource_or_scope
|
||||
|
||||
expire_data_after_sign_in!
|
||||
|
||||
if options[:bypass]
|
||||
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc, caller)
|
||||
[Devise] bypass option is deprecated and it will be removed in future version of Devise.
|
||||
Please use bypass_sign_in method instead.
|
||||
Example:
|
||||
|
||||
bypass_sign_in(user)
|
||||
DEPRECATION
|
||||
warden.session_serializer.store(resource, scope)
|
||||
elsif warden.user(scope) == resource && !options.delete(:force)
|
||||
# Do nothing. User already signed in and we are not forcing it.
|
||||
true
|
||||
else
|
||||
warden.set_user(resource, options.merge!(scope: scope))
|
||||
end
|
||||
end
|
||||
|
||||
# Sign in a user bypassing the warden callbacks and stores the user
|
||||
# straight in session. This option is useful in cases the user is already
|
||||
# signed in, but we want to refresh the credentials in session.
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# bypass_sign_in @user, scope: :user
|
||||
# bypass_sign_in @user
|
||||
def bypass_sign_in(resource, scope: nil)
|
||||
scope ||= Devise::Mapping.find_scope!(resource)
|
||||
expire_data_after_sign_in!
|
||||
warden.session_serializer.store(resource, scope)
|
||||
end
|
||||
|
||||
# Sign out a given user or scope. This helper is useful for signing out a user
|
||||
# after deleting accounts. Returns true if there was a logout and false if there
|
||||
# is no user logged in on the referred scope
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# sign_out :user # sign_out(scope)
|
||||
# sign_out @user # sign_out(resource)
|
||||
#
|
||||
def sign_out(resource_or_scope=nil)
|
||||
return sign_out_all_scopes unless resource_or_scope
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
user = warden.user(scope: scope, run_callbacks: false) # If there is no user
|
||||
|
||||
warden.logout(scope)
|
||||
warden.clear_strategies_cache!(scope: scope)
|
||||
instance_variable_set(:"@current_#{scope}", nil)
|
||||
|
||||
!!user
|
||||
end
|
||||
|
||||
# Sign out all active users or scopes. This helper is useful for signing out all roles
|
||||
# in one click. This signs out ALL scopes in warden. Returns true if there was at least one logout
|
||||
# and false if there was no user logged in on all scopes.
|
||||
def sign_out_all_scopes(lock=true)
|
||||
users = Devise.mappings.keys.map { |s| warden.user(scope: s, run_callbacks: false) }
|
||||
|
||||
warden.logout
|
||||
expire_data_after_sign_out!
|
||||
warden.clear_strategies_cache!
|
||||
warden.lock! if lock
|
||||
|
||||
users.any?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def expire_data_after_sign_in!
|
||||
# session.keys will return an empty array if the session is not yet loaded.
|
||||
# This is a bug in both Rack and Rails.
|
||||
# A call to #empty? forces the session to be loaded.
|
||||
session.empty?
|
||||
session.keys.grep(/^devise\./).each { |k| session.delete(k) }
|
||||
end
|
||||
|
||||
alias :expire_data_after_sign_out! :expire_data_after_sign_in!
|
||||
end
|
||||
end
|
||||
end
|
||||
76
lib/devise/controllers/store_location.rb
Normal file
76
lib/devise/controllers/store_location.rb
Normal file
@@ -0,0 +1,76 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "uri"
|
||||
|
||||
module Devise
|
||||
module Controllers
|
||||
# Provide the ability to store a location.
|
||||
# Used to redirect back to a desired path after sign in.
|
||||
# Included by default in all controllers.
|
||||
module StoreLocation
|
||||
# Returns and delete (if it's navigational format) the url stored in the session for
|
||||
# the given scope. Useful for giving redirect backs after sign up:
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# redirect_to stored_location_for(:user) || root_path
|
||||
#
|
||||
def stored_location_for(resource_or_scope)
|
||||
session_key = stored_location_key_for(resource_or_scope)
|
||||
|
||||
if is_navigational_format?
|
||||
session.delete(session_key)
|
||||
else
|
||||
session[session_key]
|
||||
end
|
||||
end
|
||||
|
||||
# Stores the provided location to redirect the user after signing in.
|
||||
# Useful in combination with the `stored_location_for` helper.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# store_location_for(:user, dashboard_path)
|
||||
# redirect_to user_facebook_omniauth_authorize_path
|
||||
#
|
||||
def store_location_for(resource_or_scope, location)
|
||||
session_key = stored_location_key_for(resource_or_scope)
|
||||
|
||||
path = extract_path_from_location(location)
|
||||
session[session_key] = path if path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parse_uri(location)
|
||||
location && URI.parse(location)
|
||||
rescue URI::InvalidURIError
|
||||
nil
|
||||
end
|
||||
|
||||
def stored_location_key_for(resource_or_scope)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
"#{scope}_return_to"
|
||||
end
|
||||
|
||||
def extract_path_from_location(location)
|
||||
uri = parse_uri(location)
|
||||
|
||||
if uri
|
||||
path = remove_domain_from_uri(uri)
|
||||
path = add_fragment_back_to_path(uri, path)
|
||||
|
||||
path
|
||||
end
|
||||
end
|
||||
|
||||
def remove_domain_from_uri(uri)
|
||||
[uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')
|
||||
end
|
||||
|
||||
def add_fragment_back_to_path(uri, path)
|
||||
[path, uri.fragment].compact.join('#')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Controllers
|
||||
# Create url helpers to be used with resource/scope configuration. Acts as
|
||||
@@ -42,14 +44,14 @@ module Devise
|
||||
[:path, :url].each do |path_or_url|
|
||||
actions.each do |action|
|
||||
action = action ? "#{action}_" : ""
|
||||
method = "#{action}#{module_name}_#{path_or_url}"
|
||||
method = :"#{action}#{module_name}_#{path_or_url}"
|
||||
|
||||
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
|
||||
def #{method}(resource_or_scope, *args)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
_devise_route_context.send("#{action}\#{scope}_#{module_name}_#{path_or_url}", *args)
|
||||
end
|
||||
URL_HELPERS
|
||||
define_method method do |resource_or_scope, *args|
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
router_name = Devise.mappings[scope].router_name
|
||||
context = router_name ? send(router_name) : _devise_route_context
|
||||
context.send("#{action}#{scope}_#{module_name}_#{path_or_url}", *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
# Checks the scope in the given environment and returns the associated failure app.
|
||||
class Delegator
|
||||
|
||||
24
lib/devise/encryptor.rb
Normal file
24
lib/devise/encryptor.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'bcrypt'
|
||||
|
||||
module Devise
|
||||
module Encryptor
|
||||
def self.digest(klass, password)
|
||||
if klass.pepper.present?
|
||||
password = "#{password}#{klass.pepper}"
|
||||
end
|
||||
::BCrypt::Password.create(password, cost: klass.stretches).to_s
|
||||
end
|
||||
|
||||
def self.compare(klass, hashed_password, password)
|
||||
return false if hashed_password.blank?
|
||||
bcrypt = ::BCrypt::Password.new(hashed_password)
|
||||
if klass.pepper.present?
|
||||
password = "#{password}#{klass.pepper}"
|
||||
end
|
||||
password = ::BCrypt::Engine.hash_secret(password, bcrypt.salt)
|
||||
Devise.secure_compare(password, hashed_password)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,28 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "action_controller/metal"
|
||||
|
||||
module Devise
|
||||
# Failure application that will be called every time :warden is thrown from
|
||||
# any strategy or hook. Responsible for redirect the user to the sign in
|
||||
# page based on current scope and mapping. If no scope is given, redirect
|
||||
# to the default_url.
|
||||
# any strategy or hook. It is responsible for redirecting the user to the sign
|
||||
# in page based on current scope and mapping. If no scope is given, it
|
||||
# redirects to the default_url.
|
||||
class FailureApp < ActionController::Metal
|
||||
include ActionController::RackDelegation
|
||||
include ActionController::UrlFor
|
||||
include ActionController::Redirecting
|
||||
|
||||
include Rails.application.routes.url_helpers
|
||||
include Rails.application.routes.mounted_helpers
|
||||
|
||||
delegate :flash, :to => :request
|
||||
include Devise::Controllers::StoreLocation
|
||||
|
||||
delegate :flash, to: :request
|
||||
|
||||
def self.call(env)
|
||||
@respond ||= action(:respond)
|
||||
@respond.call(env)
|
||||
end
|
||||
|
||||
# Try retrieving the URL options from the parent controller (usually
|
||||
# ApplicationController). Instance methods are not supported at the moment,
|
||||
# so only the class-level attribute is used.
|
||||
def self.default_url_options(*args)
|
||||
if defined?(ApplicationController)
|
||||
ApplicationController.default_url_options(*args)
|
||||
if defined?(Devise.parent_controller.constantize)
|
||||
Devise.parent_controller.constantize.try(:default_url_options) || {}
|
||||
else
|
||||
{}
|
||||
end
|
||||
@@ -46,30 +52,62 @@ module Devise
|
||||
end
|
||||
|
||||
def recall
|
||||
env["PATH_INFO"] = attempted_path
|
||||
flash.now[:alert] = i18n_message(:invalid)
|
||||
self.response = recall_app(warden_options[:recall]).call(env)
|
||||
header_info = if relative_url_root?
|
||||
base_path = Pathname.new(relative_url_root)
|
||||
full_path = Pathname.new(attempted_path)
|
||||
|
||||
{ "SCRIPT_NAME" => relative_url_root,
|
||||
"PATH_INFO" => '/' + full_path.relative_path_from(base_path).to_s }
|
||||
else
|
||||
{ "PATH_INFO" => attempted_path }
|
||||
end
|
||||
|
||||
header_info.each do | var, value|
|
||||
if request.respond_to?(:set_header)
|
||||
request.set_header(var, value)
|
||||
else
|
||||
request.env[var] = value
|
||||
end
|
||||
end
|
||||
|
||||
flash.now[:alert] = i18n_message(:invalid) if is_flashing_format?
|
||||
# self.response = recall_app(warden_options[:recall]).call(env)
|
||||
self.response = recall_app(warden_options[:recall]).call(request.env)
|
||||
end
|
||||
|
||||
def redirect
|
||||
store_location!
|
||||
if flash[:timedout] && flash[:alert]
|
||||
flash.keep(:timedout)
|
||||
flash.keep(:alert)
|
||||
else
|
||||
flash[:alert] = i18n_message
|
||||
if is_flashing_format?
|
||||
if flash[:timedout] && flash[:alert]
|
||||
flash.keep(:timedout)
|
||||
flash.keep(:alert)
|
||||
else
|
||||
flash[:alert] = i18n_message
|
||||
end
|
||||
end
|
||||
redirect_to redirect_url
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def i18n_options(options)
|
||||
options
|
||||
end
|
||||
|
||||
def i18n_message(default = nil)
|
||||
message = warden_message || default || :unauthenticated
|
||||
|
||||
if message.is_a?(Symbol)
|
||||
I18n.t(:"#{scope}.#{message}", :resource_name => scope,
|
||||
:scope => "devise.failure", :default => [message])
|
||||
options = {}
|
||||
options[:resource_name] = scope
|
||||
options[:scope] = "devise.failure"
|
||||
options[:default] = [message]
|
||||
auth_keys = scope_class.authentication_keys
|
||||
keys = (auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys).map { |key| scope_class.human_attribute_name(key) }
|
||||
options[:authentication_keys] = keys.join(I18n.translate(:"support.array.words_connector"))
|
||||
options = i18n_options(options)
|
||||
|
||||
I18n.t(:"#{scope}.#{message}", options)
|
||||
else
|
||||
message.to_s
|
||||
end
|
||||
@@ -77,7 +115,7 @@ module Devise
|
||||
|
||||
def redirect_url
|
||||
if warden_message == :timeout
|
||||
flash[:timedout] = true
|
||||
flash[:timedout] = true if is_flashing_format?
|
||||
|
||||
path = if request.get?
|
||||
attempted_path
|
||||
@@ -85,26 +123,45 @@ module Devise
|
||||
request.referrer
|
||||
end
|
||||
|
||||
path || scope_path
|
||||
path || scope_url
|
||||
else
|
||||
scope_path
|
||||
scope_url
|
||||
end
|
||||
end
|
||||
|
||||
def scope_path
|
||||
def route(scope)
|
||||
:"new_#{scope}_session_url"
|
||||
end
|
||||
|
||||
def scope_url
|
||||
opts = {}
|
||||
route = :"new_#{scope}_session_path"
|
||||
|
||||
# Initialize script_name with nil to prevent infinite loops in
|
||||
# authenticated mounted engines in rails 4.2 and 5.0
|
||||
opts[:script_name] = nil
|
||||
|
||||
route = route(scope)
|
||||
|
||||
opts[:format] = request_format unless skip_format?
|
||||
|
||||
config = Rails.application.config
|
||||
opts[:script_name] = (config.relative_url_root if config.respond_to?(:relative_url_root))
|
||||
router_name = Devise.mappings[scope].router_name || Devise.available_router_name
|
||||
context = send(router_name)
|
||||
|
||||
context = send(Devise.available_router_name)
|
||||
if relative_url_root?
|
||||
opts[:script_name] = relative_url_root
|
||||
|
||||
# We need to add the rootpath to `script_name` manually for applications that use a Rails
|
||||
# version lower than 5.1. Otherwise, it is going to generate a wrong path for Engines
|
||||
# that use Devise. Remove it when the support of Rails 5.0 is droped.
|
||||
elsif root_path_defined?(context) && !rails_51_and_up?
|
||||
rootpath = context.routes.url_helpers.root_path
|
||||
opts[:script_name] = rootpath.chomp('/') if rootpath.length > 1
|
||||
end
|
||||
|
||||
if context.respond_to?(route)
|
||||
context.send(route, opts)
|
||||
elsif respond_to?(:root_path)
|
||||
root_path(opts)
|
||||
elsif respond_to?(:root_url)
|
||||
root_url(opts)
|
||||
else
|
||||
"/"
|
||||
end
|
||||
@@ -114,12 +171,12 @@ module Devise
|
||||
%w(html */*).include? request_format.to_s
|
||||
end
|
||||
|
||||
# Choose whether we should respond in a http authentication fashion,
|
||||
# Choose whether we should respond in an HTTP authentication fashion,
|
||||
# including 401 and optional headers.
|
||||
#
|
||||
# This method allows the user to explicitly disable http authentication
|
||||
# on ajax requests in case they want to redirect on failures instead of
|
||||
# handling the errors on their own. This is useful in case your ajax API
|
||||
# This method allows the user to explicitly disable HTTP authentication
|
||||
# on AJAX requests in case they want to redirect on failures instead of
|
||||
# handling the errors on their own. This is useful in case your AJAX API
|
||||
# is the same as your public API and uses a format like JSON (so you
|
||||
# cannot mark JSON as a navigational format).
|
||||
def http_auth?
|
||||
@@ -130,19 +187,19 @@ module Devise
|
||||
end
|
||||
end
|
||||
|
||||
# It does not make sense to send authenticate headers in ajax requests
|
||||
# It doesn't make sense to send authenticate headers in AJAX requests
|
||||
# or if the user disabled them.
|
||||
def http_auth_header?
|
||||
Devise.mappings[scope].to.http_authenticatable && !request.xhr?
|
||||
scope_class.http_authenticatable && !request.xhr?
|
||||
end
|
||||
|
||||
def http_auth_body
|
||||
return i18n_message unless request_format
|
||||
method = "to_#{request_format}"
|
||||
if method == "to_xml"
|
||||
{ :error => i18n_message }.to_xml(:root => "errors")
|
||||
{ error: i18n_message }.to_xml(root: "errors")
|
||||
elsif {}.respond_to?(method)
|
||||
{ :error => i18n_message }.send(method)
|
||||
{ error: i18n_message }.send(method)
|
||||
else
|
||||
i18n_message
|
||||
end
|
||||
@@ -156,11 +213,11 @@ module Devise
|
||||
end
|
||||
|
||||
def warden
|
||||
env['warden']
|
||||
request.respond_to?(:get_header) ? request.get_header("warden") : request.env["warden"]
|
||||
end
|
||||
|
||||
def warden_options
|
||||
env['warden.options']
|
||||
request.respond_to?(:get_header) ? request.get_header("warden.options") : request.env["warden.options"]
|
||||
end
|
||||
|
||||
def warden_message
|
||||
@@ -171,24 +228,58 @@ module Devise
|
||||
@scope ||= warden_options[:scope] || Devise.default_scope
|
||||
end
|
||||
|
||||
def scope_class
|
||||
@scope_class ||= Devise.mappings[scope].to
|
||||
end
|
||||
|
||||
def attempted_path
|
||||
warden_options[:attempted_path]
|
||||
end
|
||||
|
||||
# Stores requested uri to redirect the user after signing in. We cannot use
|
||||
# scoped session provided by warden here, since the user is not authenticated
|
||||
# yet, but we still need to store the uri based on scope, so different scopes
|
||||
# would never use the same uri to redirect.
|
||||
# Stores requested URI to redirect the user after signing in. We can't use
|
||||
# the scoped session provided by warden here, since the user is not
|
||||
# authenticated yet, but we still need to store the URI based on scope, so
|
||||
# different scopes would never use the same URI to redirect.
|
||||
def store_location!
|
||||
session["#{scope}_return_to"] = attempted_path if request.get? && !http_auth?
|
||||
store_location_for(scope, attempted_path) if request.get? && !http_auth?
|
||||
end
|
||||
|
||||
def is_navigational_format?
|
||||
Devise.navigational_formats.include?(request_format)
|
||||
end
|
||||
|
||||
# Check if flash messages should be emitted. Default is to do it on
|
||||
# navigational formats
|
||||
def is_flashing_format?
|
||||
request.respond_to?(:flash) && is_navigational_format?
|
||||
end
|
||||
|
||||
def request_format
|
||||
@request_format ||= request.format.try(:ref)
|
||||
end
|
||||
|
||||
def relative_url_root
|
||||
@relative_url_root ||= begin
|
||||
config = Rails.application.config
|
||||
|
||||
config.try(:relative_url_root) || config.action_controller.try(:relative_url_root)
|
||||
end
|
||||
end
|
||||
|
||||
def relative_url_root?
|
||||
relative_url_root.present?
|
||||
end
|
||||
|
||||
ActiveSupport.run_load_hooks(:devise_failure_app, self)
|
||||
|
||||
private
|
||||
|
||||
def root_path_defined?(context)
|
||||
defined?(context.routes) && context.routes.url_helpers.respond_to?(:root_path)
|
||||
end
|
||||
|
||||
def rails_51_and_up?
|
||||
Rails.gem_version >= Gem::Version.new("5.1")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
# Deny user access whenever his account is not active yet. All strategies that inherits from
|
||||
# Devise::Strategies::Authenticatable and uses the validate already check if the user is active_for_authentication?
|
||||
# before actively signing him in. However, we need this as hook to validate the user activity
|
||||
# in each request and in case the user is using other strategies beside Devise ones.
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Deny user access whenever their account is not active yet.
|
||||
# We need this as hook to validate the user activity on each request
|
||||
# and in case the user is using other strategies beside Devise ones.
|
||||
Warden::Manager.after_set_user do |record, warden, options|
|
||||
if record && record.respond_to?(:active_for_authentication?) && !record.active_for_authentication?
|
||||
scope = options[:scope]
|
||||
warden.logout(scope)
|
||||
throw :warden, :scope => scope, :message => record.inactive_message
|
||||
throw :warden, scope: scope, message: record.inactive_message
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Warden::Manager.after_authentication do |record, warden, options|
|
||||
if Devise.clean_up_csrf_token_on_authentication
|
||||
clean_up_for_winning_strategy = !warden.winning_strategy.respond_to?(:clean_up_csrf?) ||
|
||||
warden.winning_strategy.clean_up_csrf?
|
||||
if Devise.clean_up_csrf_token_on_authentication && clean_up_for_winning_strategy
|
||||
warden.request.session.try(:delete, :_csrf_token)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Before logout hook to forget the user in the given scope, if it responds
|
||||
# to forget_me! Also clear remember token to ensure the user won't be
|
||||
# remembered again. Notice that we forget the user unless the record is not persisted.
|
||||
# This avoids forgetting deleted users.
|
||||
Warden::Manager.before_logout do |record, warden, options|
|
||||
if record.respond_to?(:forget_me!)
|
||||
Devise::Controllers::Rememberable::Proxy.new(warden).forget_me(record)
|
||||
Devise::Hooks::Proxy.new(warden).forget_me(record)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# After each sign in, if resource responds to failed_attempts, sets it to 0
|
||||
# This is only triggered when the user is explicitly set (with set_user)
|
||||
Warden::Manager.after_set_user :except => :fetch do |record, warden, options|
|
||||
Warden::Manager.after_set_user except: :fetch do |record, warden, options|
|
||||
if record.respond_to?(:failed_attempts) && warden.authenticated?(options[:scope])
|
||||
record.update_attribute(:failed_attempts, 0) unless record.failed_attempts.to_i.zero?
|
||||
unless record.failed_attempts.to_i.zero?
|
||||
record.failed_attempts = 0
|
||||
record.save(validate: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
23
lib/devise/hooks/proxy.rb
Normal file
23
lib/devise/hooks/proxy.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Hooks
|
||||
# A small warden proxy so we can remember, forget and
|
||||
# sign out users from hooks.
|
||||
class Proxy #:nodoc:
|
||||
include Devise::Controllers::Rememberable
|
||||
include Devise::Controllers::SignInOut
|
||||
|
||||
attr_reader :warden
|
||||
delegate :cookies, :request, to: :warden
|
||||
|
||||
def initialize(warden)
|
||||
@warden = warden
|
||||
end
|
||||
|
||||
def session
|
||||
warden.request.session
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,7 +1,9 @@
|
||||
Warden::Manager.after_set_user :except => :fetch do |record, warden, options|
|
||||
# frozen_string_literal: true
|
||||
|
||||
Warden::Manager.after_set_user except: :fetch do |record, warden, options|
|
||||
scope = options[:scope]
|
||||
if record.respond_to?(:remember_me) && options[:store] != false &&
|
||||
record.remember_me && warden.authenticated?(scope)
|
||||
Devise::Controllers::Rememberable::Proxy.new(warden).remember_me(record)
|
||||
Devise::Hooks::Proxy.new(warden).remember_me(record)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Each time a record is set we check whether its session has already timed out
|
||||
# or not, based on last request time. If so, the record is logged out and
|
||||
# redirected to the sign in page. Also, each time the request comes and the
|
||||
@@ -7,19 +9,27 @@ Warden::Manager.after_set_user do |record, warden, options|
|
||||
scope = options[:scope]
|
||||
env = warden.request.env
|
||||
|
||||
if record && record.respond_to?(:timedout?) && warden.authenticated?(scope) && options[:store] != false
|
||||
if record && record.respond_to?(:timedout?) && warden.authenticated?(scope) &&
|
||||
options[:store] != false && !env['devise.skip_timeoutable']
|
||||
last_request_at = warden.session(scope)['last_request_at']
|
||||
|
||||
if record.timedout?(last_request_at) && !env['devise.skip_timeout']
|
||||
warden.logout(scope)
|
||||
if record.respond_to?(:expire_auth_token_on_timeout) && record.expire_auth_token_on_timeout
|
||||
record.reset_authentication_token!
|
||||
end
|
||||
throw :warden, :scope => scope, :message => :timeout
|
||||
if last_request_at.is_a? Integer
|
||||
last_request_at = Time.at(last_request_at).utc
|
||||
elsif last_request_at.is_a? String
|
||||
last_request_at = Time.parse(last_request_at)
|
||||
end
|
||||
|
||||
proxy = Devise::Hooks::Proxy.new(warden)
|
||||
|
||||
if record.timedout?(last_request_at) &&
|
||||
!env['devise.skip_timeout'] &&
|
||||
!proxy.remember_me_is_active?(record)
|
||||
Devise.sign_out_all_scopes ? proxy.sign_out : proxy.sign_out(scope)
|
||||
throw :warden, scope: scope, message: :timeout
|
||||
end
|
||||
|
||||
unless env['devise.skip_trackable']
|
||||
warden.session(scope)['last_request_at'] = Time.now.utc
|
||||
warden.session(scope)['last_request_at'] = Time.now.utc.to_i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# After each sign in, update sign in time, sign in count and sign in IP.
|
||||
# This is only triggered when the user is explicitly set (with set_user)
|
||||
# and on authentication. Retrieving the user from session (:fetch) does
|
||||
# not trigger it.
|
||||
Warden::Manager.after_set_user :except => :fetch do |record, warden, options|
|
||||
Warden::Manager.after_set_user except: :fetch do |record, warden, options|
|
||||
if record.respond_to?(:update_tracked_fields!) && warden.authenticated?(options[:scope]) && !warden.request.env['devise.skip_trackable']
|
||||
record.update_tracked_fields!(warden.request)
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Mailers
|
||||
module Helpers
|
||||
@@ -5,15 +7,16 @@ module Devise
|
||||
|
||||
included do
|
||||
include Devise::Controllers::ScopedViews
|
||||
attr_reader :scope_name, :resource
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
attr_reader :scope_name, :resource
|
||||
|
||||
# Configure default email options
|
||||
def devise_mail(record, action, opts={})
|
||||
def devise_mail(record, action, opts = {}, &block)
|
||||
initialize_from_record(record)
|
||||
mail headers_for(action, opts)
|
||||
mail headers_for(action, opts), &block
|
||||
end
|
||||
|
||||
def initialize_from_record(record)
|
||||
@@ -27,12 +30,12 @@ module Devise
|
||||
|
||||
def headers_for(action, opts)
|
||||
headers = {
|
||||
:subject => subject_for(action),
|
||||
:to => resource.email,
|
||||
:from => mailer_sender(devise_mapping),
|
||||
:reply_to => mailer_reply_to(devise_mapping),
|
||||
:template_path => template_paths,
|
||||
:template_name => action
|
||||
subject: subject_for(action),
|
||||
to: resource.email,
|
||||
from: mailer_sender(devise_mapping),
|
||||
reply_to: mailer_reply_to(devise_mapping),
|
||||
template_path: template_paths,
|
||||
template_name: action
|
||||
}.merge(opts)
|
||||
|
||||
@email = headers[:to]
|
||||
@@ -64,7 +67,7 @@ module Devise
|
||||
template_path
|
||||
end
|
||||
|
||||
# Setup a subject doing an I18n lookup. At first, it attempts to set a subject
|
||||
# Set up a subject doing an I18n lookup. At first, it attempts to set a subject
|
||||
# based on the current mapping:
|
||||
#
|
||||
# en:
|
||||
@@ -82,8 +85,8 @@ module Devise
|
||||
# subject: '...'
|
||||
#
|
||||
def subject_for(key)
|
||||
I18n.t(:"#{devise_mapping.name}_subject", :scope => [:devise, :mailer, key],
|
||||
:default => [:subject, key.to_s.humanize])
|
||||
I18n.t(:"#{devise_mapping.name}_subject", scope: [:devise, :mailer, key],
|
||||
default: [:subject, key.to_s.humanize])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
# Responsible for handling devise mappings and routes configuration. Each
|
||||
# resource configured by devise_for in routes is actually creating a mapping
|
||||
@@ -23,16 +25,18 @@ module Devise
|
||||
#
|
||||
class Mapping #:nodoc:
|
||||
attr_reader :singular, :scoped_path, :path, :controllers, :path_names,
|
||||
:class_name, :sign_out_via, :format, :used_routes, :used_helpers, :failure_app
|
||||
:class_name, :sign_out_via, :format, :used_routes, :used_helpers,
|
||||
:failure_app, :router_name
|
||||
|
||||
alias :name :singular
|
||||
|
||||
# Receives an object and find a scope for it. If a scope cannot be found,
|
||||
# raises an error. If a symbol is given, it's considered to be the scope.
|
||||
def self.find_scope!(obj)
|
||||
obj = obj.devise_scope if obj.respond_to?(:devise_scope)
|
||||
case obj
|
||||
when String, Symbol
|
||||
return obj
|
||||
return obj.to_sym
|
||||
when Class
|
||||
Devise.mappings.each_value { |m| return m.name if obj <= m.to }
|
||||
else
|
||||
@@ -60,6 +64,8 @@ module Devise
|
||||
@sign_out_via = options[:sign_out_via] || Devise.sign_out_via
|
||||
@format = options[:format]
|
||||
|
||||
@router_name = options[:router_name]
|
||||
|
||||
default_failure_app(options)
|
||||
default_controllers(options)
|
||||
default_path_names(options)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
class MissingAttribute < StandardError
|
||||
@@ -12,7 +14,7 @@ module Devise
|
||||
|
||||
# Creates configuration values for Devise and for the given module.
|
||||
#
|
||||
# Devise::Models.config(Devise::Authenticatable, :stretches, 10)
|
||||
# Devise::Models.config(Devise::Models::DatabaseAuthenticatable, :stretches)
|
||||
#
|
||||
# The line above creates:
|
||||
#
|
||||
@@ -84,11 +86,6 @@ module Devise
|
||||
devise_modules_hook! do
|
||||
include Devise::Models::Authenticatable
|
||||
|
||||
if selected_modules.include?(:token_authenticatable)
|
||||
ActiveSupport::Deprecation.warn "devise :token_authenticatable is deprecated. " \
|
||||
"Please check Devise 3.1 release notes for more information on how to upgrade."
|
||||
end
|
||||
|
||||
selected_modules.each do |m|
|
||||
mod = Devise::Models.const_get(m.to_s.classify)
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'devise/hooks/activatable'
|
||||
require 'devise/hooks/csrf_cleaner'
|
||||
|
||||
@@ -29,9 +31,7 @@ module Devise
|
||||
# It also accepts an array specifying the strategies that should allow params authentication.
|
||||
#
|
||||
# * +skip_session_storage+: By default Devise will store the user in session.
|
||||
# You can skip storage for http and token auth by appending values to array:
|
||||
# :skip_session_storage => [:token_auth] or :skip_session_storage => [:http_auth, :token_auth],
|
||||
# by default is set to :skip_session_storage => [:http_auth].
|
||||
# By default is set to skip_session_storage: [:http_auth].
|
||||
#
|
||||
# == active_for_authentication?
|
||||
#
|
||||
@@ -39,7 +39,7 @@ module Devise
|
||||
# calling model.active_for_authentication?. This method is overwritten by other devise modules. For instance,
|
||||
# :confirmable overwrites .active_for_authentication? to only return true if your model was confirmed.
|
||||
#
|
||||
# You overwrite this method yourself, but if you do, don't forget to call super:
|
||||
# You can overwrite this method yourself, but if you do, don't forget to call super:
|
||||
#
|
||||
# def active_for_authentication?
|
||||
# super && special_condition_is_valid?
|
||||
@@ -58,10 +58,10 @@ module Devise
|
||||
BLACKLIST_FOR_SERIALIZATION = [:encrypted_password, :reset_password_token, :reset_password_sent_at,
|
||||
:remember_created_at, :sign_in_count, :current_sign_in_at, :last_sign_in_at, :current_sign_in_ip,
|
||||
:last_sign_in_ip, :password_salt, :confirmation_token, :confirmed_at, :confirmation_sent_at,
|
||||
:remember_token, :unconfirmed_email, :failed_attempts, :unlock_token, :locked_at, :authentication_token]
|
||||
:remember_token, :unconfirmed_email, :failed_attempts, :unlock_token, :locked_at]
|
||||
|
||||
included do
|
||||
class_attribute :devise_modules, :instance_writer => false
|
||||
class_attribute :devise_modules, instance_writer: false
|
||||
self.devise_modules ||= []
|
||||
|
||||
before_validation :downcase_keys
|
||||
@@ -97,29 +97,31 @@ module Devise
|
||||
def authenticatable_salt
|
||||
end
|
||||
|
||||
array = %w(serializable_hash)
|
||||
# to_xml does not call serializable_hash on 3.1
|
||||
array << "to_xml" if Rails::VERSION::STRING[0,3] == "3.1"
|
||||
# Redefine serializable_hash in models for more secure defaults.
|
||||
# By default, it removes from the serializable model all attributes that
|
||||
# are *not* accessible. You can remove this default by using :force_except
|
||||
# and passing a new list of attributes you want to exempt. All attributes
|
||||
# given to :except will simply add names to exempt to Devise internal list.
|
||||
def serializable_hash(options = nil)
|
||||
options = options.try(:dup) || {}
|
||||
options[:except] = Array(options[:except])
|
||||
|
||||
array.each do |method|
|
||||
class_eval <<-RUBY, __FILE__, __LINE__
|
||||
# Redefine to_xml and serializable_hash in models for more secure defaults.
|
||||
# By default, it removes from the serializable model all attributes that
|
||||
# are *not* accessible. You can remove this default by using :force_except
|
||||
# and passing a new list of attributes you want to exempt. All attributes
|
||||
# given to :except will simply add names to exempt to Devise internal list.
|
||||
def #{method}(options=nil)
|
||||
options ||= {}
|
||||
options[:except] = Array(options[:except])
|
||||
if options[:force_except]
|
||||
options[:except].concat Array(options[:force_except])
|
||||
else
|
||||
options[:except].concat BLACKLIST_FOR_SERIALIZATION
|
||||
end
|
||||
|
||||
if options[:force_except]
|
||||
options[:except].concat Array(options[:force_except])
|
||||
else
|
||||
options[:except].concat BLACKLIST_FOR_SERIALIZATION
|
||||
end
|
||||
super(options)
|
||||
end
|
||||
RUBY
|
||||
super(options)
|
||||
end
|
||||
|
||||
# Redefine inspect using serializable_hash, to ensure we don't accidentally
|
||||
# leak passwords into exceptions.
|
||||
def inspect
|
||||
inspection = serializable_hash.collect do |k,v|
|
||||
"#{k}: #{respond_to?(:attribute_for_inspect) ? attribute_for_inspect(k) : v.inspect}"
|
||||
end
|
||||
"#<#{self.class} #{inspection.join(", ")}>"
|
||||
end
|
||||
|
||||
protected
|
||||
@@ -129,18 +131,20 @@ module Devise
|
||||
end
|
||||
|
||||
# This is an internal method called every time Devise needs
|
||||
# to send a notification/mail. This can be overriden if you
|
||||
# to send a notification/mail. This can be overridden if you
|
||||
# need to customize the e-mail delivery logic. For instance,
|
||||
# if you are using a queue to deliver e-mails (delayed job,
|
||||
# sidekiq, resque, etc), you must add the delivery to the queue
|
||||
# if you are using a queue to deliver e-mails (active job, delayed
|
||||
# job, sidekiq, resque, etc), you must add the delivery to the queue
|
||||
# just after the transaction was committed. To achieve this,
|
||||
# you can override send_devise_notification to store the
|
||||
# deliveries until the after_commit callback is triggered:
|
||||
# deliveries until the after_commit callback is triggered.
|
||||
#
|
||||
# The following example uses Active Job's `deliver_later` :
|
||||
#
|
||||
# class User
|
||||
# devise :database_authenticatable, :confirmable
|
||||
#
|
||||
# after_commit :send_pending_notifications
|
||||
# after_commit :send_pending_devise_notifications
|
||||
#
|
||||
# protected
|
||||
#
|
||||
@@ -149,50 +153,74 @@ module Devise
|
||||
# # delivery until the after_commit callback otherwise
|
||||
# # send now because after_commit will not be called.
|
||||
# if new_record? || changed?
|
||||
# pending_notifications << [notification, args]
|
||||
# pending_devise_notifications << [notification, args]
|
||||
# else
|
||||
# devise_mailer.send(notification, self, *args).deliver
|
||||
# render_and_send_devise_message(notification, *args)
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# def send_pending_notifications
|
||||
# pending_notifications.each do |notification, args|
|
||||
# devise_mailer.send(notification, self, *args).deliver
|
||||
# private
|
||||
#
|
||||
# def send_pending_devise_notifications
|
||||
# pending_devise_notifications.each do |notification, args|
|
||||
# render_and_send_devise_message(notification, *args)
|
||||
# end
|
||||
#
|
||||
# # Empty the pending notifications array because the
|
||||
# # after_commit hook can be called multiple times which
|
||||
# # could cause multiple emails to be sent.
|
||||
# pending_notifications.clear
|
||||
# pending_devise_notifications.clear
|
||||
# end
|
||||
#
|
||||
# def pending_notifications
|
||||
# @pending_notifications ||= []
|
||||
# def pending_devise_notifications
|
||||
# @pending_devise_notifications ||= []
|
||||
# end
|
||||
#
|
||||
# def render_and_send_devise_message(notification, *args)
|
||||
# message = devise_mailer.send(notification, self, *args)
|
||||
#
|
||||
# # Deliver later with Active Job's `deliver_later`
|
||||
# if message.respond_to?(:deliver_later)
|
||||
# message.deliver_later
|
||||
# # Remove once we move to Rails 4.2+ only, as `deliver` is deprecated.
|
||||
# elsif message.respond_to?(:deliver_now)
|
||||
# message.deliver_now
|
||||
# else
|
||||
# message.deliver
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# end
|
||||
#
|
||||
def send_devise_notification(notification, *args)
|
||||
devise_mailer.send(notification, self, *args).deliver
|
||||
message = devise_mailer.send(notification, self, *args)
|
||||
# Remove once we move to Rails 4.2+ only.
|
||||
if message.respond_to?(:deliver_now)
|
||||
message.deliver_now
|
||||
else
|
||||
message.deliver
|
||||
end
|
||||
end
|
||||
|
||||
def downcase_keys
|
||||
self.class.case_insensitive_keys.each { |k| apply_to_attribute_or_variable(k, :downcase!) }
|
||||
self.class.case_insensitive_keys.each { |k| apply_to_attribute_or_variable(k, :downcase) }
|
||||
end
|
||||
|
||||
def strip_whitespace
|
||||
self.class.strip_whitespace_keys.each { |k| apply_to_attribute_or_variable(k, :strip!) }
|
||||
self.class.strip_whitespace_keys.each { |k| apply_to_attribute_or_variable(k, :strip) }
|
||||
end
|
||||
|
||||
def apply_to_attribute_or_variable(attr, method)
|
||||
if self[attr]
|
||||
self[attr].try(method)
|
||||
self[attr] = self[attr].try(method)
|
||||
|
||||
# Use respond_to? here to avoid a regression where globally
|
||||
# configured strip_whitespace_keys or case_insensitive_keys were
|
||||
# attempting to strip! or downcase! when a model didn't have the
|
||||
# attempting to strip or downcase when a model didn't have the
|
||||
# globally configured key.
|
||||
elsif respond_to?(attr)
|
||||
send(attr).try(method)
|
||||
elsif respond_to?(attr) && respond_to?("#{attr}=")
|
||||
new_value = send(attr).try(method)
|
||||
send("#{attr}=", new_value)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -232,11 +260,11 @@ module Devise
|
||||
# Example:
|
||||
#
|
||||
# def self.find_for_authentication(tainted_conditions)
|
||||
# find_first_by_auth_conditions(tainted_conditions, :active => true)
|
||||
# find_first_by_auth_conditions(tainted_conditions, active: true)
|
||||
# end
|
||||
#
|
||||
# Finally, notice that Devise also queries for users in other scenarios
|
||||
# besides authentication, for example when retrieving an user to send
|
||||
# besides authentication, for example when retrieving a user to send
|
||||
# an e-mail for password reset. In such cases, find_for_authentication
|
||||
# is not called.
|
||||
def find_for_authentication(tainted_conditions)
|
||||
@@ -247,31 +275,27 @@ module Devise
|
||||
to_adapter.find_first(devise_parameter_filter.filter(tainted_conditions).merge(opts))
|
||||
end
|
||||
|
||||
# Find an initialize a record setting an error if it can't be found.
|
||||
# Find or initialize a record setting an error if it can't be found.
|
||||
def find_or_initialize_with_error_by(attribute, value, error=:invalid) #:nodoc:
|
||||
find_or_initialize_with_errors([attribute], { attribute => value }, error)
|
||||
end
|
||||
|
||||
# Find an initialize a group of attributes based on a list of required attributes.
|
||||
# Find or initialize a record with group of attributes based on a list of required attributes.
|
||||
def find_or_initialize_with_errors(required_attributes, attributes, error=:invalid) #:nodoc:
|
||||
attributes = attributes.slice(*required_attributes)
|
||||
attributes.delete_if { |key, value| value.blank? }
|
||||
attributes.try(:permit!)
|
||||
attributes = attributes.to_h.with_indifferent_access
|
||||
.slice(*required_attributes)
|
||||
.delete_if { |key, value| value.blank? }
|
||||
|
||||
if attributes.size == required_attributes.size
|
||||
record = find_first_by_auth_conditions(attributes)
|
||||
record = find_first_by_auth_conditions(attributes) and return record
|
||||
end
|
||||
|
||||
unless record
|
||||
record = new
|
||||
|
||||
new(devise_parameter_filter.filter(attributes)).tap do |record|
|
||||
required_attributes.each do |key|
|
||||
value = attributes[key]
|
||||
record.send("#{key}=", value)
|
||||
record.errors.add(key, value.present? ? error : :blank)
|
||||
record.errors.add(key, attributes[key].blank? ? :blank : error)
|
||||
end
|
||||
end
|
||||
|
||||
record
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
# Confirmable is responsible to verify if an account is already confirmed to
|
||||
@@ -5,42 +7,60 @@ module Devise
|
||||
# Confirmation instructions are sent to the user email after creating a
|
||||
# record and when manually requested by a new confirmation instruction request.
|
||||
#
|
||||
# Confirmable tracks the following columns:
|
||||
#
|
||||
# * confirmation_token - A unique random token
|
||||
# * confirmed_at - A timestamp when the user clicked the confirmation link
|
||||
# * confirmation_sent_at - A timestamp when the confirmation_token was generated (not sent)
|
||||
# * unconfirmed_email - An email address copied from the email attr. After confirmation
|
||||
# this value is copied to the email attr then cleared
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
# Confirmable adds the following options to +devise+:
|
||||
#
|
||||
# * +allow_unconfirmed_access_for+: the time you want to allow the user to access his account
|
||||
# * +allow_unconfirmed_access_for+: the time you want to allow the user to access their account
|
||||
# before confirming it. After this period, the user access is denied. You can
|
||||
# use this to let your user access some features of your application without
|
||||
# confirming the account, but blocking it after a certain period (ie 7 days).
|
||||
# By default allow_unconfirmed_access_for is zero, it means users always have to confirm to sign in.
|
||||
# * +reconfirmable+: requires any email changes to be confirmed (exactly the same way as
|
||||
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
||||
# db field to be setup (t.reconfirmable in migrations). Until confirmed new email is
|
||||
# db field to be set up (t.reconfirmable in migrations). Until confirmed, new email is
|
||||
# stored in unconfirmed email column, and copied to email column on successful
|
||||
# confirmation.
|
||||
# confirmation. Also, when used in conjunction with `send_email_changed_notification`,
|
||||
# the notification is sent to the original email when the change is requested,
|
||||
# not when the unconfirmed email is confirmed.
|
||||
# * +confirm_within+: the time before a sent confirmation token becomes invalid.
|
||||
# You can use this to force the user to confirm within a set period of time.
|
||||
# Confirmable will not generate a new token if a repeat confirmation is requested
|
||||
# during this time frame, unless the user's email changed too.
|
||||
#
|
||||
# == Examples
|
||||
#
|
||||
# User.find(1).confirm! # returns true unless it's already confirmed
|
||||
# User.find(1).confirm # returns true unless it's already confirmed
|
||||
# User.find(1).confirmed? # true/false
|
||||
# User.find(1).send_confirmation_instructions # manually send instructions
|
||||
#
|
||||
module Confirmable
|
||||
extend ActiveSupport::Concern
|
||||
include ActionView::Helpers::DateHelper
|
||||
|
||||
included do
|
||||
before_create :generate_confirmation_token, :if => :confirmation_required?
|
||||
after_create :send_on_create_confirmation_instructions, :if => :send_confirmation_notification?
|
||||
before_update :postpone_email_change_until_confirmation_and_regenerate_confirmation_token, :if => :postpone_email_change?
|
||||
after_update :send_reconfirmation_instructions, :if => :reconfirmation_required?
|
||||
before_create :generate_confirmation_token, if: :confirmation_required?
|
||||
after_create :skip_reconfirmation_in_callback!, if: :send_confirmation_notification?
|
||||
if defined?(ActiveRecord) && self < ActiveRecord::Base # ActiveRecord
|
||||
after_commit :send_on_create_confirmation_instructions, on: :create, if: :send_confirmation_notification?
|
||||
after_commit :send_reconfirmation_instructions, on: :update, if: :reconfirmation_required?
|
||||
else # Mongoid
|
||||
after_create :send_on_create_confirmation_instructions, if: :send_confirmation_notification?
|
||||
after_update :send_reconfirmation_instructions, if: :reconfirmation_required?
|
||||
end
|
||||
before_update :postpone_email_change_until_confirmation_and_regenerate_confirmation_token, if: :postpone_email_change?
|
||||
end
|
||||
|
||||
def initialize(*args, &block)
|
||||
@bypass_confirmation_postpone = false
|
||||
@skip_reconfirmation_in_callback = false
|
||||
@reconfirmation_required = false
|
||||
@skip_confirmation_notification = false
|
||||
@raw_confirmation_token = nil
|
||||
@@ -56,26 +76,25 @@ module Devise
|
||||
# Confirm a user by setting it's confirmed_at to actual time. If the user
|
||||
# is already confirmed, add an error to email field. If the user is invalid
|
||||
# add errors
|
||||
def confirm!
|
||||
def confirm(args={})
|
||||
pending_any_confirmation do
|
||||
if confirmation_period_expired?
|
||||
self.errors.add(:email, :confirmation_period_expired,
|
||||
:period => Devise::TimeInflector.time_ago_in_words(self.class.confirm_within.ago))
|
||||
period: Devise::TimeInflector.time_ago_in_words(self.class.confirm_within.ago))
|
||||
return false
|
||||
end
|
||||
|
||||
self.confirmation_token = nil
|
||||
self.confirmed_at = Time.now.utc
|
||||
|
||||
saved = if self.class.reconfirmable && unconfirmed_email.present?
|
||||
saved = if pending_reconfirmation?
|
||||
skip_reconfirmation!
|
||||
self.email = unconfirmed_email
|
||||
self.unconfirmed_email = nil
|
||||
|
||||
# We need to validate in such cases to enforce e-mail uniqueness
|
||||
save(:validate => true)
|
||||
save(validate: true)
|
||||
else
|
||||
save(:validate => false)
|
||||
save(validate: args[:ensure_valid] == true)
|
||||
end
|
||||
|
||||
after_confirmation if saved
|
||||
@@ -98,7 +117,7 @@ module Devise
|
||||
generate_confirmation_token!
|
||||
end
|
||||
|
||||
opts = pending_reconfirmation? ? { :to => unconfirmed_email } : { }
|
||||
opts = pending_reconfirmation? ? { to: unconfirmed_email } : { }
|
||||
send_devise_notification(:confirmation_instructions, @raw_confirmation_token, opts)
|
||||
end
|
||||
|
||||
@@ -151,8 +170,14 @@ module Devise
|
||||
|
||||
protected
|
||||
|
||||
# To not require reconfirmation after creating with #save called in a
|
||||
# callback call skip_create_confirmation!
|
||||
def skip_reconfirmation_in_callback!
|
||||
@skip_reconfirmation_in_callback = true
|
||||
end
|
||||
|
||||
# A callback method used to deliver confirmation
|
||||
# instructions on creation. This can be overriden
|
||||
# instructions on creation. This can be overridden
|
||||
# in models to map to a nice sign up e-mail.
|
||||
def send_on_create_confirmation_instructions
|
||||
send_confirmation_instructions
|
||||
@@ -166,7 +191,7 @@ module Devise
|
||||
# Checks if the confirmation for the user is within the limit time.
|
||||
# We do this by calculating if the difference between today and the
|
||||
# confirmation sent date does not exceed the confirm in time configured.
|
||||
# Confirm_within is a model configuration, must always be an integer value.
|
||||
# allow_unconfirmed_access_for is a model configuration, must always be an integer value.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
@@ -186,7 +211,10 @@ module Devise
|
||||
# confirmation_period_valid? # will always return true
|
||||
#
|
||||
def confirmation_period_valid?
|
||||
self.class.allow_unconfirmed_access_for.nil? || (confirmation_sent_at && confirmation_sent_at.utc >= self.class.allow_unconfirmed_access_for.ago)
|
||||
return true if self.class.allow_unconfirmed_access_for.nil?
|
||||
return false if self.class.allow_unconfirmed_access_for == 0.days
|
||||
|
||||
confirmation_sent_at && confirmation_sent_at.utc >= self.class.allow_unconfirmed_access_for.ago
|
||||
end
|
||||
|
||||
# Checks if the user confirmation happens before the token becomes invalid
|
||||
@@ -202,7 +230,7 @@ module Devise
|
||||
# confirmation_period_expired? # will always return false
|
||||
#
|
||||
def confirmation_period_expired?
|
||||
self.class.confirm_within && (Time.now > self.confirmation_sent_at + self.class.confirm_within )
|
||||
self.class.confirm_within && self.confirmation_sent_at && (Time.now.utc > self.confirmation_sent_at.utc + self.class.confirm_within)
|
||||
end
|
||||
|
||||
# Checks whether the record requires any confirmation.
|
||||
@@ -216,39 +244,88 @@ module Devise
|
||||
end
|
||||
|
||||
# Generates a new random token for confirmation, and stores
|
||||
# the time this token is being generated
|
||||
# the time this token is being generated in confirmation_sent_at
|
||||
def generate_confirmation_token
|
||||
raw, enc = Devise.token_generator.generate(self.class, :confirmation_token)
|
||||
@raw_confirmation_token = raw
|
||||
self.confirmation_token = enc
|
||||
self.confirmation_sent_at = Time.now.utc
|
||||
if self.confirmation_token && !confirmation_period_expired?
|
||||
@raw_confirmation_token = self.confirmation_token
|
||||
else
|
||||
self.confirmation_token = @raw_confirmation_token = Devise.friendly_token
|
||||
self.confirmation_sent_at = Time.now.utc
|
||||
end
|
||||
end
|
||||
|
||||
def generate_confirmation_token!
|
||||
generate_confirmation_token && save(:validate => false)
|
||||
generate_confirmation_token && save(validate: false)
|
||||
end
|
||||
|
||||
def postpone_email_change_until_confirmation_and_regenerate_confirmation_token
|
||||
@reconfirmation_required = true
|
||||
self.unconfirmed_email = self.email
|
||||
self.email = self.email_was
|
||||
generate_confirmation_token
|
||||
if Devise.activerecord51?
|
||||
def postpone_email_change_until_confirmation_and_regenerate_confirmation_token
|
||||
@reconfirmation_required = true
|
||||
self.unconfirmed_email = self.email
|
||||
self.email = self.email_in_database
|
||||
self.confirmation_token = nil
|
||||
generate_confirmation_token
|
||||
end
|
||||
else
|
||||
def postpone_email_change_until_confirmation_and_regenerate_confirmation_token
|
||||
@reconfirmation_required = true
|
||||
self.unconfirmed_email = self.email
|
||||
self.email = self.email_was
|
||||
self.confirmation_token = nil
|
||||
generate_confirmation_token
|
||||
end
|
||||
end
|
||||
|
||||
def postpone_email_change?
|
||||
postpone = self.class.reconfirmable && email_changed? && !@bypass_confirmation_postpone && !self.email.blank?
|
||||
@bypass_confirmation_postpone = false
|
||||
postpone
|
||||
if Devise.activerecord51?
|
||||
def postpone_email_change?
|
||||
postpone = self.class.reconfirmable &&
|
||||
will_save_change_to_email? &&
|
||||
!@bypass_confirmation_postpone &&
|
||||
self.email.present? &&
|
||||
(!@skip_reconfirmation_in_callback || !self.email_in_database.nil?)
|
||||
@bypass_confirmation_postpone = false
|
||||
postpone
|
||||
end
|
||||
else
|
||||
def postpone_email_change?
|
||||
postpone = self.class.reconfirmable &&
|
||||
email_changed? &&
|
||||
!@bypass_confirmation_postpone &&
|
||||
self.email.present? &&
|
||||
(!@skip_reconfirmation_in_callback || !self.email_was.nil?)
|
||||
@bypass_confirmation_postpone = false
|
||||
postpone
|
||||
end
|
||||
end
|
||||
|
||||
def reconfirmation_required?
|
||||
self.class.reconfirmable && @reconfirmation_required && !self.email.blank?
|
||||
self.class.reconfirmable && @reconfirmation_required && (self.email.present? || self.unconfirmed_email.present?)
|
||||
end
|
||||
|
||||
def send_confirmation_notification?
|
||||
confirmation_required? && !@skip_confirmation_notification && !self.email.blank?
|
||||
confirmation_required? && !@skip_confirmation_notification && self.email.present?
|
||||
end
|
||||
|
||||
# With reconfirmable, notify the original email when the user first
|
||||
# requests the email change, instead of when the change is confirmed.
|
||||
def send_email_changed_notification?
|
||||
if self.class.reconfirmable
|
||||
self.class.send_email_changed_notification && reconfirmation_required?
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
# A callback initiated after successfully confirming. This can be
|
||||
# used to insert your own logic that is only run after the user successfully
|
||||
# confirms.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# def after_confirmation
|
||||
# self.update_attribute(:invite_code, nil)
|
||||
# end
|
||||
#
|
||||
def after_confirmation
|
||||
end
|
||||
|
||||
@@ -271,21 +348,23 @@ module Devise
|
||||
# If the user is already confirmed, create an error for the user
|
||||
# Options must have the confirmation_token
|
||||
def confirm_by_token(confirmation_token)
|
||||
original_token = confirmation_token
|
||||
confirmation_token = Devise.token_generator.digest(self, :confirmation_token, confirmation_token)
|
||||
|
||||
confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
|
||||
if !confirmable.persisted? && Devise.allow_insecure_token_lookup
|
||||
confirmable = find_or_initialize_with_error_by(:confirmation_token, original_token)
|
||||
confirmable = find_first_by_auth_conditions(confirmation_token: confirmation_token)
|
||||
unless confirmable
|
||||
confirmation_digest = Devise.token_generator.digest(self, :confirmation_token, confirmation_token)
|
||||
confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_digest)
|
||||
end
|
||||
|
||||
confirmable.confirm! if confirmable.persisted?
|
||||
confirmable.confirmation_token = original_token
|
||||
# TODO: replace above lines with
|
||||
# confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
|
||||
# after enough time has passed that Devise clients do not use digested tokens
|
||||
|
||||
confirmable.confirm if confirmable.persisted?
|
||||
confirmable
|
||||
end
|
||||
|
||||
# Find a record for confirmation by unconfirmed email field
|
||||
def find_by_unconfirmed_email_with_errors(attributes = {})
|
||||
attributes = attributes.slice(*confirmation_keys).permit!.to_h if attributes.respond_to? :permit
|
||||
unconfirmed_required_attributes = confirmation_keys.map { |k| k == :email ? :unconfirmed_email : k }
|
||||
unconfirmed_attributes = attributes.symbolize_keys
|
||||
unconfirmed_attributes[:unconfirmed_email] = unconfirmed_attributes.delete(:email)
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'devise/strategies/database_authenticatable'
|
||||
require 'bcrypt'
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
# Authenticatable Module, responsible for encrypting password and validating
|
||||
# authenticity of a user while signing in.
|
||||
# Authenticatable Module, responsible for hashing the password and
|
||||
# validating the authenticity of a user while signing in.
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
# DatabaseAuthenticable adds the following options to devise_for:
|
||||
# DatabaseAuthenticatable adds the following options to devise_for:
|
||||
#
|
||||
# * +pepper+: a random string used to provide a more secure hash. Use
|
||||
# `rake secret` to generate new keys.
|
||||
# `rails secret` to generate new keys.
|
||||
#
|
||||
# * +stretches+: the cost given to bcrypt.
|
||||
#
|
||||
# * +send_email_changed_notification+: notify original email when it changes.
|
||||
#
|
||||
# * +send_password_change_notification+: notify email when password changes.
|
||||
#
|
||||
# == Examples
|
||||
#
|
||||
# User.find(1).valid_password?('password123') # returns true/false
|
||||
@@ -23,26 +28,44 @@ module Devise
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
after_update :send_email_changed_notification, if: :send_email_changed_notification?
|
||||
after_update :send_password_change_notification, if: :send_password_change_notification?
|
||||
|
||||
attr_reader :password, :current_password
|
||||
attr_accessor :password_confirmation
|
||||
end
|
||||
|
||||
def initialize(*args, &block)
|
||||
@skip_email_changed_notification = false
|
||||
@skip_password_change_notification = false
|
||||
super
|
||||
end
|
||||
|
||||
# Skips sending the email changed notification after_update
|
||||
def skip_email_changed_notification!
|
||||
@skip_email_changed_notification = true
|
||||
end
|
||||
|
||||
# Skips sending the password change notification after_update
|
||||
def skip_password_change_notification!
|
||||
@skip_password_change_notification = true
|
||||
end
|
||||
|
||||
def self.required_fields(klass)
|
||||
[:encrypted_password] + klass.authentication_keys
|
||||
end
|
||||
|
||||
# Generates password encryption based on the given value.
|
||||
# Generates a hashed password based on the given value.
|
||||
# For legacy reasons, we use `encrypted_password` to store
|
||||
# the hashed password.
|
||||
def password=(new_password)
|
||||
@password = new_password
|
||||
self.encrypted_password = password_digest(@password) if @password.present?
|
||||
end
|
||||
|
||||
# Verifies whether an password (ie from sign in) is the user password.
|
||||
# Verifies whether a password (ie from sign in) is the user password.
|
||||
def valid_password?(password)
|
||||
return false if encrypted_password.blank?
|
||||
bcrypt = ::BCrypt::Password.new(encrypted_password)
|
||||
password = ::BCrypt::Engine.hash_secret("#{password}#{self.class.pepper}", bcrypt.salt)
|
||||
Devise.secure_compare(password, encrypted_password)
|
||||
Devise::Encryptor.compare(self.class, encrypted_password, password)
|
||||
end
|
||||
|
||||
# Set password and password confirmation to nil
|
||||
@@ -50,10 +73,23 @@ module Devise
|
||||
self.password = self.password_confirmation = nil
|
||||
end
|
||||
|
||||
# Update record attributes when :current_password matches, otherwise returns
|
||||
# error on :current_password. It also automatically rejects :password and
|
||||
# :password_confirmation if they are blank.
|
||||
# Update record attributes when :current_password matches, otherwise
|
||||
# returns error on :current_password.
|
||||
#
|
||||
# This method also rejects the password field if it is blank (allowing
|
||||
# users to change relevant information like the e-mail without changing
|
||||
# their password). In case the password field is rejected, the confirmation
|
||||
# is also rejected as long as it is also blank.
|
||||
def update_with_password(params, *options)
|
||||
if options.present?
|
||||
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
|
||||
[Devise] The second argument of `DatabaseAuthenticatable#update_with_password`
|
||||
(`options`) is deprecated and it will be removed in the next major version.
|
||||
It was added to support a feature deprecated in Rails 4, so you can safely remove it
|
||||
from your code.
|
||||
DEPRECATION
|
||||
end
|
||||
|
||||
current_password = params.delete(:current_password)
|
||||
|
||||
if params[:password].blank?
|
||||
@@ -62,11 +98,11 @@ module Devise
|
||||
end
|
||||
|
||||
result = if valid_password?(current_password)
|
||||
update_attributes(params, *options)
|
||||
update(params, *options)
|
||||
else
|
||||
self.assign_attributes(params, *options)
|
||||
self.valid?
|
||||
self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)
|
||||
assign_attributes(params, *options)
|
||||
valid?
|
||||
errors.add(:current_password, current_password.blank? ? :blank : :invalid)
|
||||
false
|
||||
end
|
||||
|
||||
@@ -87,29 +123,48 @@ module Devise
|
||||
# end
|
||||
#
|
||||
def update_without_password(params, *options)
|
||||
if options.present?
|
||||
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
|
||||
[Devise] The second argument of `DatabaseAuthenticatable#update_without_password`
|
||||
(`options`) is deprecated and it will be removed in the next major version.
|
||||
It was added to support a feature deprecated in Rails 4, so you can safely remove it
|
||||
from your code.
|
||||
DEPRECATION
|
||||
end
|
||||
|
||||
params.delete(:password)
|
||||
params.delete(:password_confirmation)
|
||||
|
||||
result = update_attributes(params, *options)
|
||||
result = update(params, *options)
|
||||
clean_up_passwords
|
||||
result
|
||||
end
|
||||
|
||||
# Destroy record when :current_password matches, otherwise returns
|
||||
# error on :current_password. It also automatically rejects
|
||||
# error on :current_password. It also automatically rejects
|
||||
# :current_password if it is blank.
|
||||
def destroy_with_password(current_password)
|
||||
result = if valid_password?(current_password)
|
||||
destroy
|
||||
else
|
||||
self.valid?
|
||||
self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)
|
||||
valid?
|
||||
errors.add(:current_password, current_password.blank? ? :blank : :invalid)
|
||||
false
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
# A callback initiated after successfully authenticating. This can be
|
||||
# used to insert your own logic that is only run after the user successfully
|
||||
# authenticates.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# def after_database_authentication
|
||||
# self.update_attribute(:invite_code, nil)
|
||||
# end
|
||||
#
|
||||
def after_database_authentication
|
||||
end
|
||||
|
||||
@@ -118,15 +173,56 @@ module Devise
|
||||
encrypted_password[0,29] if encrypted_password
|
||||
end
|
||||
|
||||
if Devise.activerecord51?
|
||||
# Send notification to user when email changes.
|
||||
def send_email_changed_notification
|
||||
send_devise_notification(:email_changed, to: email_before_last_save)
|
||||
end
|
||||
else
|
||||
# Send notification to user when email changes.
|
||||
def send_email_changed_notification
|
||||
send_devise_notification(:email_changed, to: email_was)
|
||||
end
|
||||
end
|
||||
|
||||
# Send notification to user when password changes.
|
||||
def send_password_change_notification
|
||||
send_devise_notification(:password_change)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Digests the password using bcrypt.
|
||||
# Hashes the password using bcrypt. Custom hash functions should override
|
||||
# this method to apply their own algorithm.
|
||||
#
|
||||
# See https://github.com/plataformatec/devise-encryptable for examples
|
||||
# of other hashing engines.
|
||||
def password_digest(password)
|
||||
::BCrypt::Password.create("#{password}#{self.class.pepper}", :cost => self.class.stretches).to_s
|
||||
Devise::Encryptor.digest(self.class, password)
|
||||
end
|
||||
|
||||
if Devise.activerecord51?
|
||||
def send_email_changed_notification?
|
||||
self.class.send_email_changed_notification && saved_change_to_email? && !@skip_email_changed_notification
|
||||
end
|
||||
else
|
||||
def send_email_changed_notification?
|
||||
self.class.send_email_changed_notification && email_changed? && !@skip_email_changed_notification
|
||||
end
|
||||
end
|
||||
|
||||
if Devise.activerecord51?
|
||||
def send_password_change_notification?
|
||||
self.class.send_password_change_notification && saved_change_to_encrypted_password? && !@skip_password_change_notification
|
||||
end
|
||||
else
|
||||
def send_password_change_notification?
|
||||
self.class.send_password_change_notification && encrypted_password_changed? && !@skip_password_change_notification
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
Devise::Models.config(self, :pepper, :stretches)
|
||||
Devise::Models.config(self, :pepper, :stretches, :send_email_changed_notification, :send_password_change_notification)
|
||||
|
||||
# We assume this method already gets the sanitized values from the
|
||||
# DatabaseAuthenticatable strategy. If you are using this method on
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "devise/hooks/lockable"
|
||||
|
||||
module Devise
|
||||
@@ -7,7 +9,7 @@ module Devise
|
||||
# blocked: email and time. The former will send an email to the user when
|
||||
# the lock happens, containing a link to unlock its account. The second
|
||||
# will unlock the user automatically after some configured time (ie 2.hours).
|
||||
# It's also possible to setup lockable to use both email and time strategies.
|
||||
# It's also possible to set up lockable to use both email and time strategies.
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
@@ -22,7 +24,7 @@ module Devise
|
||||
module Lockable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
delegate :lock_strategy_enabled?, :unlock_strategy_enabled?, :to => "self.class"
|
||||
delegate :lock_strategy_enabled?, :unlock_strategy_enabled?, to: "self.class"
|
||||
|
||||
def self.required_fields(klass)
|
||||
attributes = []
|
||||
@@ -34,13 +36,16 @@ module Devise
|
||||
end
|
||||
|
||||
# Lock a user setting its locked_at to actual time.
|
||||
def lock_access!
|
||||
# * +opts+: Hash options if you don't want to send email
|
||||
# when you lock access, you could pass the next hash
|
||||
# `{ send_instructions: false } as option`.
|
||||
def lock_access!(opts = { })
|
||||
self.locked_at = Time.now.utc
|
||||
|
||||
if unlock_strategy_enabled?(:email)
|
||||
if unlock_strategy_enabled?(:email) && opts.fetch(:send_instructions, true)
|
||||
send_unlock_instructions
|
||||
else
|
||||
save(:validate => false)
|
||||
save(validate: false)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,7 +54,7 @@ module Devise
|
||||
self.locked_at = nil
|
||||
self.failed_attempts = 0 if respond_to?(:failed_attempts=)
|
||||
self.unlock_token = nil if respond_to?(:unlock_token=)
|
||||
save(:validate => false)
|
||||
save(validate: false)
|
||||
end
|
||||
|
||||
# Verifies whether a user is locked or not.
|
||||
@@ -61,7 +66,7 @@ module Devise
|
||||
def send_unlock_instructions
|
||||
raw, enc = Devise.token_generator.generate(self.class, :unlock_token)
|
||||
self.unlock_token = enc
|
||||
self.save(:validate => false)
|
||||
save(validate: false)
|
||||
send_devise_notification(:unlock_instructions, raw, {})
|
||||
raw
|
||||
end
|
||||
@@ -96,24 +101,30 @@ module Devise
|
||||
if super && !access_locked?
|
||||
true
|
||||
else
|
||||
self.failed_attempts ||= 0
|
||||
self.failed_attempts += 1
|
||||
increment_failed_attempts
|
||||
if attempts_exceeded?
|
||||
lock_access! unless access_locked?
|
||||
else
|
||||
save(:validate => false)
|
||||
save(validate: false)
|
||||
end
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def increment_failed_attempts
|
||||
self.class.increment_counter(:failed_attempts, id)
|
||||
reload
|
||||
end
|
||||
|
||||
def unauthenticated_message
|
||||
# If set to paranoid mode, do not show the locked message because it
|
||||
# leaks the existence of an account.
|
||||
if Devise.paranoid
|
||||
super
|
||||
elsif lock_strategy_enabled?(:failed_attempts) && attempts_exceeded?
|
||||
elsif access_locked? || (lock_strategy_enabled?(:failed_attempts) && attempts_exceeded?)
|
||||
:locked
|
||||
elsif lock_strategy_enabled?(:failed_attempts) && last_attempt? && self.class.last_attempt_warning
|
||||
:last_attempt
|
||||
else
|
||||
super
|
||||
end
|
||||
@@ -122,7 +133,11 @@ module Devise
|
||||
protected
|
||||
|
||||
def attempts_exceeded?
|
||||
self.failed_attempts > self.class.maximum_attempts
|
||||
self.failed_attempts >= self.class.maximum_attempts
|
||||
end
|
||||
|
||||
def last_attempt?
|
||||
self.failed_attempts == self.class.maximum_attempts - 1
|
||||
end
|
||||
|
||||
# Tells if the lock is expired if :time unlock strategy is active
|
||||
@@ -146,6 +161,9 @@ module Devise
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
# List of strategies that are enabled/supported if :both is used.
|
||||
BOTH_STRATEGIES = [:time, :email]
|
||||
|
||||
# Attempt to find a user by its unlock keys. If a record is found, send new
|
||||
# unlock instructions to it. If not user is found, returns a new user
|
||||
# with an email not found error.
|
||||
@@ -165,10 +183,6 @@ module Devise
|
||||
unlock_token = Devise.token_generator.digest(self, :unlock_token, unlock_token)
|
||||
|
||||
lockable = find_or_initialize_with_error_by(:unlock_token, unlock_token)
|
||||
if !lockable.persisted? && Devise.allow_insecure_token_lookup
|
||||
lockable = find_or_initialize_with_error_by(:unlock_token, original_token)
|
||||
end
|
||||
|
||||
lockable.unlock_access! if lockable.persisted?
|
||||
lockable.unlock_token = original_token
|
||||
lockable
|
||||
@@ -176,7 +190,8 @@ module Devise
|
||||
|
||||
# Is the unlock enabled for the given unlock strategy?
|
||||
def unlock_strategy_enabled?(strategy)
|
||||
[:both, strategy].include?(self.unlock_strategy)
|
||||
self.unlock_strategy == strategy ||
|
||||
(self.unlock_strategy == :both && BOTH_STRATEGIES.include?(strategy))
|
||||
end
|
||||
|
||||
# Is the lock enabled for the given lock strategy?
|
||||
@@ -184,7 +199,7 @@ module Devise
|
||||
self.lock_strategy == strategy
|
||||
end
|
||||
|
||||
Devise::Models.config(self, :maximum_attempts, :lock_strategy, :unlock_strategy, :unlock_in, :unlock_keys)
|
||||
Devise::Models.config(self, :maximum_attempts, :lock_strategy, :unlock_strategy, :unlock_in, :unlock_keys, :last_attempt_warning)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'devise/omniauth'
|
||||
|
||||
module Devise
|
||||
@@ -10,7 +12,7 @@ module Devise
|
||||
#
|
||||
# * +omniauth_providers+: Which providers are available to this model. It expects an array:
|
||||
#
|
||||
# devise_for :database_authenticatable, :omniauthable, :omniauth_providers => [:twitter]
|
||||
# devise_for :database_authenticatable, :omniauthable, omniauth_providers: [:twitter]
|
||||
#
|
||||
module Omniauthable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
|
||||
@@ -8,15 +10,13 @@ module Devise
|
||||
# Recoverable adds the following options to devise_for:
|
||||
#
|
||||
# * +reset_password_keys+: the keys you want to use when recovering the password for an account
|
||||
# * +reset_password_within+: the time period within which the password must be reset or the token expires.
|
||||
# * +sign_in_after_reset_password+: whether or not to sign in the user automatically after a password reset.
|
||||
#
|
||||
# == Examples
|
||||
#
|
||||
# # resets the user password and save the record, true if valid passwords are given, otherwise false
|
||||
# User.find(1).reset_password!('password123', 'password123')
|
||||
#
|
||||
# # only resets the user password, without saving the record
|
||||
# user = User.find(1)
|
||||
# user.reset_password('password123', 'password123')
|
||||
# User.find(1).reset_password('password123', 'password123')
|
||||
#
|
||||
# # creates a new token and send it with instructions about how to reset the password
|
||||
# User.find(1).send_reset_password_instructions
|
||||
@@ -28,31 +28,30 @@ module Devise
|
||||
[:reset_password_sent_at, :reset_password_token]
|
||||
end
|
||||
|
||||
included do
|
||||
before_update :clear_reset_password_token, if: :clear_reset_password_token?
|
||||
end
|
||||
|
||||
# Update password saving the record and clearing token. Returns true if
|
||||
# the passwords are valid and the record was saved, false otherwise.
|
||||
def reset_password!(new_password, new_password_confirmation)
|
||||
self.password = new_password
|
||||
self.password_confirmation = new_password_confirmation
|
||||
|
||||
if valid?
|
||||
clear_reset_password_token
|
||||
after_password_reset
|
||||
def reset_password(new_password, new_password_confirmation)
|
||||
if new_password.present?
|
||||
self.password = new_password
|
||||
self.password_confirmation = new_password_confirmation
|
||||
save
|
||||
else
|
||||
errors.add(:password, :blank)
|
||||
false
|
||||
end
|
||||
|
||||
save
|
||||
end
|
||||
|
||||
# Resets reset password token and send reset password instructions by email.
|
||||
# Returns the token sent in the e-mail.
|
||||
def send_reset_password_instructions
|
||||
raw, enc = Devise.token_generator.generate(self.class, :reset_password_token)
|
||||
token = set_reset_password_token
|
||||
send_reset_password_instructions_notification(token)
|
||||
|
||||
self.reset_password_token = enc
|
||||
self.reset_password_sent_at = Time.now.utc
|
||||
self.save(:validate => false)
|
||||
|
||||
send_devise_notification(:reset_password_instructions, raw, {})
|
||||
raw
|
||||
token
|
||||
end
|
||||
|
||||
# Checks if the reset password token sent is within the limit time.
|
||||
@@ -76,7 +75,7 @@ module Devise
|
||||
# reset_password_period_valid? # will always return false
|
||||
#
|
||||
def reset_password_period_valid?
|
||||
reset_password_sent_at && reset_password_sent_at.utc >= self.class.reset_password_within.ago
|
||||
reset_password_sent_at && reset_password_sent_at.utc >= self.class.reset_password_within.ago.utc
|
||||
end
|
||||
|
||||
protected
|
||||
@@ -87,10 +86,47 @@ module Devise
|
||||
self.reset_password_sent_at = nil
|
||||
end
|
||||
|
||||
def after_password_reset
|
||||
def set_reset_password_token
|
||||
raw, enc = Devise.token_generator.generate(self.class, :reset_password_token)
|
||||
|
||||
self.reset_password_token = enc
|
||||
self.reset_password_sent_at = Time.now.utc
|
||||
save(validate: false)
|
||||
raw
|
||||
end
|
||||
|
||||
def send_reset_password_instructions_notification(token)
|
||||
send_devise_notification(:reset_password_instructions, token, {})
|
||||
end
|
||||
|
||||
if Devise.activerecord51?
|
||||
def clear_reset_password_token?
|
||||
encrypted_password_changed = respond_to?(:will_save_change_to_encrypted_password?) && will_save_change_to_encrypted_password?
|
||||
authentication_keys_changed = self.class.authentication_keys.any? do |attribute|
|
||||
respond_to?("will_save_change_to_#{attribute}?") && send("will_save_change_to_#{attribute}?")
|
||||
end
|
||||
|
||||
authentication_keys_changed || encrypted_password_changed
|
||||
end
|
||||
else
|
||||
def clear_reset_password_token?
|
||||
encrypted_password_changed = respond_to?(:encrypted_password_changed?) && encrypted_password_changed?
|
||||
authentication_keys_changed = self.class.authentication_keys.any? do |attribute|
|
||||
respond_to?("#{attribute}_changed?") && send("#{attribute}_changed?")
|
||||
end
|
||||
|
||||
authentication_keys_changed || encrypted_password_changed
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
# Attempt to find a user by password reset token. If a user is found, return it
|
||||
# If a user is not found, return nil
|
||||
def with_reset_password_token(token)
|
||||
reset_password_token = Devise.token_generator.digest(self, :reset_password_token, token)
|
||||
to_adapter.find_first(reset_password_token: reset_password_token)
|
||||
end
|
||||
|
||||
# Attempt to find a user by its email. If a record is found, send new
|
||||
# password instructions to it. If user is not found, returns a new user
|
||||
# with an email not found error.
|
||||
@@ -101,11 +137,6 @@ module Devise
|
||||
recoverable
|
||||
end
|
||||
|
||||
# Generate a token checking if one does not already exist in the database.
|
||||
def reset_password_token
|
||||
generate_token(:reset_password_token)
|
||||
end
|
||||
|
||||
# Attempt to find a user by its reset_password_token to reset its
|
||||
# password. If a user is found and token is still valid, reset its password and automatically
|
||||
# try saving the record. If not user is found, returns a new user
|
||||
@@ -116,23 +147,20 @@ module Devise
|
||||
reset_password_token = Devise.token_generator.digest(self, :reset_password_token, original_token)
|
||||
|
||||
recoverable = find_or_initialize_with_error_by(:reset_password_token, reset_password_token)
|
||||
if !recoverable.persisted? && Devise.allow_insecure_token_lookup
|
||||
recoverable = find_or_initialize_with_error_by(:reset_password_token, original_token)
|
||||
end
|
||||
|
||||
if recoverable.persisted?
|
||||
if recoverable.reset_password_period_valid?
|
||||
recoverable.reset_password!(attributes[:password], attributes[:password_confirmation])
|
||||
recoverable.reset_password(attributes[:password], attributes[:password_confirmation])
|
||||
else
|
||||
recoverable.errors.add(:reset_password_token, :expired)
|
||||
end
|
||||
end
|
||||
|
||||
recoverable.reset_password_token = original_token
|
||||
recoverable.reset_password_token = original_token if recoverable.reset_password_token.present?
|
||||
recoverable
|
||||
end
|
||||
|
||||
Devise::Models.config(self, :reset_password_keys, :reset_password_within)
|
||||
Devise::Models.config(self, :reset_password_keys, :reset_password_within, :sign_in_after_reset_password)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
# Registerable is responsible for everything related to registering a new
|
||||
@@ -19,6 +21,8 @@ module Devise
|
||||
def new_with_session(params, session)
|
||||
new(params)
|
||||
end
|
||||
|
||||
Devise::Models.config(self, :sign_in_after_change_password)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'devise/strategies/rememberable'
|
||||
require 'devise/hooks/rememberable'
|
||||
require 'devise/hooks/forgetable'
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
# Rememberable manages generating and clearing token for remember the user
|
||||
# Rememberable manages generating and clearing token for remembering the user
|
||||
# from a saved cookie. Rememberable also has utility methods for dealing
|
||||
# with serializing the user into the cookie and back from the cookie, trying
|
||||
# to lookup the record based on the saved information.
|
||||
@@ -17,7 +19,7 @@ module Devise
|
||||
#
|
||||
# * +remember_for+: the time you want the user will be remembered without
|
||||
# asking for credentials. After this time the user will be blocked and
|
||||
# will have to enter his credentials again. This configuration is also
|
||||
# will have to enter their credentials again. This configuration is also
|
||||
# used to calculate the expires time for the cookie created to remember
|
||||
# the user. By default remember_for is 2.weeks.
|
||||
#
|
||||
@@ -39,46 +41,42 @@ module Devise
|
||||
module Rememberable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
attr_accessor :remember_me, :extend_remember_period
|
||||
attr_accessor :remember_me
|
||||
|
||||
def self.required_fields(klass)
|
||||
[:remember_created_at]
|
||||
end
|
||||
|
||||
# Generate a new remember token and save the record without validations
|
||||
# unless remember_across_browsers is true and the user already has a valid token.
|
||||
def remember_me!(extend_period=false)
|
||||
self.remember_token = self.class.remember_token if generate_remember_token?
|
||||
self.remember_created_at = Time.now.utc if generate_remember_timestamp?(extend_period)
|
||||
save(:validate => false) if self.changed?
|
||||
def remember_me!
|
||||
self.remember_token ||= self.class.remember_token if respond_to?(:remember_token)
|
||||
self.remember_created_at ||= Time.now.utc
|
||||
save(validate: false) if self.changed?
|
||||
end
|
||||
|
||||
# If the record is persisted, remove the remember token (but only if
|
||||
# it exists), and save the record without validations.
|
||||
def forget_me!
|
||||
return unless persisted?
|
||||
self.remember_token = nil if respond_to?(:remember_token=)
|
||||
self.remember_created_at = nil
|
||||
save(:validate => false)
|
||||
self.remember_token = nil if respond_to?(:remember_token)
|
||||
self.remember_created_at = nil if self.class.expire_all_remember_me_on_sign_out
|
||||
save(validate: false)
|
||||
end
|
||||
|
||||
# Remember token should be expired if expiration time not overpass now.
|
||||
def remember_expired?
|
||||
remember_created_at.nil? || (remember_expires_at <= Time.now.utc)
|
||||
end
|
||||
|
||||
# Remember token expires at created time + remember_for configuration
|
||||
def remember_expires_at
|
||||
remember_created_at + self.class.remember_for
|
||||
self.class.remember_for.from_now
|
||||
end
|
||||
|
||||
def extend_remember_period
|
||||
self.class.extend_remember_period
|
||||
end
|
||||
|
||||
def rememberable_value
|
||||
if respond_to?(:remember_token)
|
||||
remember_token
|
||||
elsif respond_to?(:authenticatable_salt) && (salt = authenticatable_salt)
|
||||
elsif respond_to?(:authenticatable_salt) && (salt = authenticatable_salt.presence)
|
||||
salt
|
||||
else
|
||||
raise "authenticable_salt returned nil for the #{self.class.name} model. " \
|
||||
raise "authenticatable_salt returned nil for the #{self.class.name} model. " \
|
||||
"In order to use rememberable, you must ensure a password is always set " \
|
||||
"or have a remember_token column in your model or implement your own " \
|
||||
"rememberable_value in the model with custom logic."
|
||||
@@ -89,40 +87,71 @@ module Devise
|
||||
self.class.rememberable_options
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def generate_remember_token? #:nodoc:
|
||||
respond_to?(:remember_token) && remember_expired?
|
||||
# A callback initiated after successfully being remembered. This can be
|
||||
# used to insert your own logic that is only run after the user is
|
||||
# remembered.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# def after_remembered
|
||||
# self.update_attribute(:invite_code, nil)
|
||||
# end
|
||||
#
|
||||
def after_remembered
|
||||
end
|
||||
|
||||
# Generate a timestamp if extend_remember_period is true, if no remember_token
|
||||
# exists, or if an existing remember token has expired.
|
||||
def generate_remember_timestamp?(extend_period) #:nodoc:
|
||||
extend_period || remember_created_at.nil? || remember_expired?
|
||||
def remember_me?(token, generated_at)
|
||||
# TODO: Normalize the JSON type coercion along with the Timeoutable hook
|
||||
# in a single place https://github.com/plataformatec/devise/blob/ffe9d6d406e79108cf32a2c6a1d0b3828849c40b/lib/devise/hooks/timeoutable.rb#L14-L18
|
||||
if generated_at.is_a?(String)
|
||||
generated_at = time_from_json(generated_at)
|
||||
end
|
||||
|
||||
# The token is only valid if:
|
||||
# 1. we have a date
|
||||
# 2. the current time does not pass the expiry period
|
||||
# 3. the record has a remember_created_at date
|
||||
# 4. the token date is bigger than the remember_created_at
|
||||
# 5. the token matches
|
||||
generated_at.is_a?(Time) &&
|
||||
(self.class.remember_for.ago < generated_at) &&
|
||||
(generated_at > (remember_created_at || Time.now).utc) &&
|
||||
Devise.secure_compare(rememberable_value, token)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def time_from_json(value)
|
||||
if value =~ /\A\d+\.\d+\Z/
|
||||
Time.at(value.to_f)
|
||||
else
|
||||
Time.parse(value) rescue nil
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
# Create the cookie key using the record id and remember_token
|
||||
def serialize_into_cookie(record)
|
||||
[record.to_key, record.rememberable_value]
|
||||
[record.to_key, record.rememberable_value, Time.now.utc.to_f.to_s]
|
||||
end
|
||||
|
||||
# Recreate the user based on the stored cookie
|
||||
def serialize_from_cookie(id, remember_token)
|
||||
def serialize_from_cookie(*args)
|
||||
id, token, generated_at = *args
|
||||
|
||||
record = to_adapter.get(id)
|
||||
record if record && !record.remember_expired? &&
|
||||
Devise.secure_compare(record.rememberable_value, remember_token)
|
||||
record if record && record.remember_me?(token, generated_at)
|
||||
end
|
||||
|
||||
# Generate a token checking if one does not already exist in the database.
|
||||
def remember_token #:nodoc:
|
||||
loop do
|
||||
token = Devise.friendly_token
|
||||
break token unless to_adapter.find_first({ :remember_token => token })
|
||||
break token unless to_adapter.find_first({ remember_token: token })
|
||||
end
|
||||
end
|
||||
|
||||
Devise::Models.config(self, :remember_for, :extend_remember_period, :rememberable_options)
|
||||
Devise::Models.config(self, :remember_for, :extend_remember_period, :rememberable_options, :expire_all_remember_me_on_sign_out)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'devise/hooks/timeoutable'
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
# Timeoutable takes care of verifyng whether a user session has already
|
||||
# Timeoutable takes care of verifying whether a user session has already
|
||||
# expired or not. When a session expires after the configured time, the user
|
||||
# will be asked for credentials again, it means, he/she will be redirected
|
||||
# will be asked for credentials again, it means, they will be redirected
|
||||
# to the sign in page.
|
||||
#
|
||||
# == Options
|
||||
@@ -26,7 +28,6 @@ module Devise
|
||||
|
||||
# Checks whether the user session has expired based on configured time.
|
||||
def timedout?(last_access)
|
||||
return false if remember_exists_and_not_expired?
|
||||
!timeout_in.nil? && last_access && last_access <= timeout_in.ago
|
||||
end
|
||||
|
||||
@@ -36,11 +37,6 @@ module Devise
|
||||
|
||||
private
|
||||
|
||||
def remember_exists_and_not_expired?
|
||||
return false unless respond_to?(:remember_created_at) && respond_to?(:remember_expired?)
|
||||
remember_created_at && !remember_expired?
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
Devise::Models.config(self, :timeout_in)
|
||||
end
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
require 'devise/strategies/token_authenticatable'
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
# The TokenAuthenticatable module is responsible for generating an authentication token and
|
||||
# validating the authenticity of the same while signing in.
|
||||
#
|
||||
# This module only provides a few helpers to help you manage the token, but it is up to you
|
||||
# to choose how to use it. For example, if you want to have a new token every time the user
|
||||
# saves his account, you can do the following:
|
||||
#
|
||||
# before_save :reset_authentication_token
|
||||
#
|
||||
# On the other hand, if you want to generate token unless one exists, you should use instead:
|
||||
#
|
||||
# before_save :ensure_authentication_token
|
||||
#
|
||||
# If you want to delete the token after it is used, you can do so in the
|
||||
# after_token_authentication callback.
|
||||
#
|
||||
# == APIs
|
||||
#
|
||||
# If you are using token authentication with APIs and using trackable. Every
|
||||
# request will be considered as a new sign in (since there is no session in
|
||||
# APIs). You can disable this by creating a before filter as follow:
|
||||
#
|
||||
# before_filter :skip_trackable
|
||||
#
|
||||
# def skip_trackable
|
||||
# request.env['devise.skip_trackable'] = true
|
||||
# end
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
# TokenAuthenticatable adds the following options to devise_for:
|
||||
#
|
||||
# * +token_authentication_key+: Defines name of the authentication token params key. E.g. /users/sign_in?some_key=...
|
||||
#
|
||||
module TokenAuthenticatable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def self.required_fields(klass)
|
||||
[:authentication_token]
|
||||
end
|
||||
|
||||
# Generate new authentication token (a.k.a. "single access token").
|
||||
def reset_authentication_token
|
||||
self.authentication_token = self.class.authentication_token
|
||||
end
|
||||
|
||||
# Generate new authentication token and save the record.
|
||||
def reset_authentication_token!
|
||||
reset_authentication_token
|
||||
save(:validate => false)
|
||||
end
|
||||
|
||||
# Generate authentication token unless already exists.
|
||||
def ensure_authentication_token
|
||||
reset_authentication_token if authentication_token.blank?
|
||||
end
|
||||
|
||||
# Generate authentication token unless already exists and save the record.
|
||||
def ensure_authentication_token!
|
||||
reset_authentication_token! if authentication_token.blank?
|
||||
end
|
||||
|
||||
# Hook called after token authentication.
|
||||
def after_token_authentication
|
||||
end
|
||||
|
||||
def expire_auth_token_on_timeout
|
||||
self.class.expire_auth_token_on_timeout
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def find_for_token_authentication(conditions)
|
||||
find_for_authentication(:authentication_token => conditions[token_authentication_key])
|
||||
end
|
||||
|
||||
# Generate a token checking if one does not already exist in the database.
|
||||
def authentication_token
|
||||
loop do
|
||||
token = Devise.friendly_token
|
||||
break token unless to_adapter.find_first({ :authentication_token => token })
|
||||
end
|
||||
end
|
||||
|
||||
Devise::Models.config(self, :token_authentication_key, :expire_auth_token_on_timeout)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'devise/hooks/trackable'
|
||||
|
||||
module Devise
|
||||
@@ -15,21 +17,35 @@ module Devise
|
||||
[:current_sign_in_at, :current_sign_in_ip, :last_sign_in_at, :last_sign_in_ip, :sign_in_count]
|
||||
end
|
||||
|
||||
def update_tracked_fields!(request)
|
||||
def update_tracked_fields(request)
|
||||
old_current, new_current = self.current_sign_in_at, Time.now.utc
|
||||
self.last_sign_in_at = old_current || new_current
|
||||
self.current_sign_in_at = new_current
|
||||
|
||||
old_current, new_current = self.current_sign_in_ip, request.remote_ip
|
||||
old_current, new_current = self.current_sign_in_ip, extract_ip_from(request)
|
||||
self.last_sign_in_ip = old_current || new_current
|
||||
self.current_sign_in_ip = new_current
|
||||
|
||||
self.sign_in_count ||= 0
|
||||
self.sign_in_count += 1
|
||||
|
||||
save(:validate => false) or raise "Devise trackable could not save #{inspect}." \
|
||||
"Please make sure a model using trackable can be saved at sign in."
|
||||
end
|
||||
|
||||
def update_tracked_fields!(request)
|
||||
# We have to check if the user is already persisted before running
|
||||
# `save` here because invalid users can be saved if we don't.
|
||||
# See https://github.com/plataformatec/devise/issues/4673 for more details.
|
||||
return if new_record?
|
||||
|
||||
update_tracked_fields(request)
|
||||
save(validate: false)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def extract_ip_from(request)
|
||||
request.remote_ip
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
# Validatable creates all needed validations for a user email and password.
|
||||
@@ -10,12 +12,12 @@ module Devise
|
||||
# Validatable adds the following options to devise_for:
|
||||
#
|
||||
# * +email_regexp+: the regular expression used to validate e-mails;
|
||||
# * +password_length+: a range expressing password length. Defaults to 8..128.
|
||||
# * +password_length+: a range expressing password length. Defaults to 6..128.
|
||||
#
|
||||
module Validatable
|
||||
# All validations used by this module.
|
||||
VALIDATIONS = [ :validates_presence_of, :validates_uniqueness_of, :validates_format_of,
|
||||
:validates_confirmation_of, :validates_length_of ].freeze
|
||||
VALIDATIONS = [:validates_presence_of, :validates_uniqueness_of, :validates_format_of,
|
||||
:validates_confirmation_of, :validates_length_of].freeze
|
||||
|
||||
def self.required_fields(klass)
|
||||
[]
|
||||
@@ -26,13 +28,18 @@ module Devise
|
||||
assert_validations_api!(base)
|
||||
|
||||
base.class_eval do
|
||||
validates_presence_of :email, :if => :email_required?
|
||||
validates_uniqueness_of :email, :allow_blank => true, :if => :email_changed?
|
||||
validates_format_of :email, :with => email_regexp, :allow_blank => true, :if => :email_changed?
|
||||
validates_presence_of :email, if: :email_required?
|
||||
if Devise.activerecord51?
|
||||
validates_uniqueness_of :email, allow_blank: true, case_sensitive: true, if: :will_save_change_to_email?
|
||||
validates_format_of :email, with: email_regexp, allow_blank: true, if: :will_save_change_to_email?
|
||||
else
|
||||
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
|
||||
validates_format_of :email, with: email_regexp, allow_blank: true, if: :email_changed?
|
||||
end
|
||||
|
||||
validates_presence_of :password, :if => :password_required?
|
||||
validates_confirmation_of :password, :if => :password_required?
|
||||
validates_length_of :password, :within => password_length, :allow_blank => true
|
||||
validates_presence_of :password, if: :password_required?
|
||||
validates_confirmation_of :password, if: :password_required?
|
||||
validates_length_of :password, within: password_length, allow_blank: true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,29 +1,30 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'active_support/core_ext/object/with_options'
|
||||
|
||||
Devise.with_options :model => true do |d|
|
||||
Devise.with_options model: true do |d|
|
||||
# Strategies first
|
||||
d.with_options :strategy => true do |s|
|
||||
d.with_options strategy: true do |s|
|
||||
routes = [nil, :new, :destroy]
|
||||
s.add_module :database_authenticatable, :controller => :sessions, :route => { :session => routes }
|
||||
s.add_module :token_authenticatable, :controller => :sessions, :route => { :session => routes }, :no_input => true
|
||||
s.add_module :rememberable, :no_input => true
|
||||
s.add_module :database_authenticatable, controller: :sessions, route: { session: routes }
|
||||
s.add_module :rememberable, no_input: true
|
||||
end
|
||||
|
||||
# Other authentications
|
||||
d.add_module :omniauthable, :controller => :omniauth_callbacks, :route => :omniauth_callback
|
||||
d.add_module :omniauthable, controller: :omniauth_callbacks, route: :omniauth_callback
|
||||
|
||||
# Misc after
|
||||
routes = [nil, :new, :edit]
|
||||
d.add_module :recoverable, :controller => :passwords, :route => { :password => routes }
|
||||
d.add_module :registerable, :controller => :registrations, :route => { :registration => (routes << :cancel) }
|
||||
d.add_module :recoverable, controller: :passwords, route: { password: routes }
|
||||
d.add_module :registerable, controller: :registrations, route: { registration: (routes << :cancel) }
|
||||
d.add_module :validatable
|
||||
|
||||
# The ones which can sign out after
|
||||
routes = [nil, :new]
|
||||
d.add_module :confirmable, :controller => :confirmations, :route => { :confirmation => routes }
|
||||
d.add_module :lockable, :controller => :unlocks, :route => { :unlock => routes }
|
||||
d.add_module :confirmable, controller: :confirmations, route: { confirmation: routes }
|
||||
d.add_module :lockable, controller: :unlocks, route: { unlock: routes }
|
||||
d.add_module :timeoutable
|
||||
|
||||
# Stats for last, so we make sure the user is really signed in
|
||||
d.add_module :trackable
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
begin
|
||||
require "omniauth"
|
||||
require "omniauth/version"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module OmniAuth
|
||||
class StrategyNotFound < NameError
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module OmniAuth
|
||||
module UrlHelpers
|
||||
def self.define_helpers(mapping)
|
||||
def omniauth_authorize_path(resource_or_scope, provider, *args)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
_devise_route_context.send("#{scope}_#{provider}_omniauth_authorize_path", *args)
|
||||
end
|
||||
|
||||
def omniauth_authorize_path(resource_or_scope, *args)
|
||||
def omniauth_authorize_url(resource_or_scope, provider, *args)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
send("#{scope}_omniauth_authorize_path", *args)
|
||||
_devise_route_context.send("#{scope}_#{provider}_omniauth_authorize_url", *args)
|
||||
end
|
||||
|
||||
def omniauth_callback_path(resource_or_scope, *args)
|
||||
def omniauth_callback_path(resource_or_scope, provider, *args)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
send("#{scope}_omniauth_callback_path", *args)
|
||||
_devise_route_context.send("#{scope}_#{provider}_omniauth_callback_path", *args)
|
||||
end
|
||||
|
||||
def omniauth_callback_url(resource_or_scope, provider, *args)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
_devise_route_context.send("#{scope}_#{provider}_omniauth_callback_url", *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'orm_adapter/adapters/active_record'
|
||||
|
||||
ActiveRecord::Base.extend Devise::Models
|
||||
ActiveSupport.on_load(:active_record) do
|
||||
extend Devise::Models
|
||||
end
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
require 'orm_adapter/adapters/mongoid'
|
||||
# frozen_string_literal: true
|
||||
|
||||
Mongoid::Document::ClassMethods.send :include, Devise::Models
|
||||
ActiveSupport.on_load(:mongoid) do
|
||||
require 'orm_adapter/adapters/mongoid'
|
||||
|
||||
Mongoid::Document::ClassMethods.send :include, Devise::Models
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
class ParameterFilter
|
||||
def initialize(case_insensitive_keys, strip_whitespace_keys)
|
||||
@@ -16,6 +18,8 @@ module Devise
|
||||
|
||||
def filtered_hash_by_method_for_given_keys(conditions, method, condition_keys)
|
||||
condition_keys.each do |k|
|
||||
next unless conditions.key?(k)
|
||||
|
||||
value = conditions[k]
|
||||
conditions[k] = value.send(method) if value.respond_to?(method)
|
||||
end
|
||||
|
||||
@@ -1,93 +1,173 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
class BaseSanitizer
|
||||
attr_reader :params, :resource_name, :resource_class
|
||||
# The +ParameterSanitizer+ deals with permitting specific parameters values
|
||||
# for each +Devise+ scope in the application.
|
||||
#
|
||||
# The sanitizer knows about Devise default parameters (like +password+ and
|
||||
# +password_confirmation+ for the `RegistrationsController`), and you can
|
||||
# extend or change the permitted parameters list on your controllers.
|
||||
#
|
||||
# === Permitting new parameters
|
||||
#
|
||||
# You can add new parameters to the permitted list using the +permit+ method
|
||||
# in a +before_action+ method, for instance.
|
||||
#
|
||||
# class ApplicationController < ActionController::Base
|
||||
# before_action :configure_permitted_parameters, if: :devise_controller?
|
||||
#
|
||||
# protected
|
||||
#
|
||||
# def configure_permitted_parameters
|
||||
# # Permit the `subscribe_newsletter` parameter along with the other
|
||||
# # sign up parameters.
|
||||
# devise_parameter_sanitizer.permit(:sign_up, keys: [:subscribe_newsletter])
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# Using a block yields an +ActionController::Parameters+ object so you can
|
||||
# permit nested parameters and have more control over how the parameters are
|
||||
# permitted in your controller.
|
||||
#
|
||||
# def configure_permitted_parameters
|
||||
# devise_parameter_sanitizer.permit(:sign_up) do |user|
|
||||
# user.permit(newsletter_preferences: [])
|
||||
# end
|
||||
# end
|
||||
class ParameterSanitizer
|
||||
DEFAULT_PERMITTED_ATTRIBUTES = {
|
||||
sign_in: [:password, :remember_me],
|
||||
sign_up: [:password, :password_confirmation],
|
||||
account_update: [:password, :password_confirmation, :current_password]
|
||||
}
|
||||
|
||||
def initialize(resource_class, resource_name, params)
|
||||
@resource_class = resource_class
|
||||
@resource_name = resource_name
|
||||
@auth_keys = extract_auth_keys(resource_class)
|
||||
@params = params
|
||||
@blocks = Hash.new
|
||||
end
|
||||
@resource_name = resource_name
|
||||
@permitted = {}
|
||||
|
||||
def for(kind, &block)
|
||||
if block_given?
|
||||
@blocks[kind] = block
|
||||
else
|
||||
default_for(kind)
|
||||
DEFAULT_PERMITTED_ATTRIBUTES.each_pair do |action, keys|
|
||||
permit(action, keys: keys)
|
||||
end
|
||||
end
|
||||
|
||||
def sanitize(kind)
|
||||
if block = @blocks[kind]
|
||||
block.call(default_params)
|
||||
# Sanitize the parameters for a specific +action+.
|
||||
#
|
||||
# === Arguments
|
||||
#
|
||||
# * +action+ - A +Symbol+ with the action that the controller is
|
||||
# performing, like +sign_up+, +sign_in+, etc.
|
||||
#
|
||||
# === Examples
|
||||
#
|
||||
# # Inside the `RegistrationsController#create` action.
|
||||
# resource = build_resource(devise_parameter_sanitizer.sanitize(:sign_up))
|
||||
# resource.save
|
||||
#
|
||||
# Returns an +ActiveSupport::HashWithIndifferentAccess+ with the permitted
|
||||
# attributes.
|
||||
def sanitize(action)
|
||||
permissions = @permitted[action]
|
||||
|
||||
if permissions.respond_to?(:call)
|
||||
cast_to_hash permissions.call(default_params)
|
||||
elsif permissions.present?
|
||||
cast_to_hash permit_keys(default_params, permissions)
|
||||
else
|
||||
default_sanitize(kind)
|
||||
unknown_action!(action)
|
||||
end
|
||||
end
|
||||
|
||||
# Add or remove new parameters to the permitted list of an +action+.
|
||||
#
|
||||
# === Arguments
|
||||
#
|
||||
# * +action+ - A +Symbol+ with the action that the controller is
|
||||
# performing, like +sign_up+, +sign_in+, etc.
|
||||
# * +keys:+ - An +Array+ of keys that also should be permitted.
|
||||
# * +except:+ - An +Array+ of keys that shouldn't be permitted.
|
||||
# * +block+ - A block that should be used to permit the action
|
||||
# parameters instead of the +Array+ based approach. The block will be
|
||||
# called with an +ActionController::Parameters+ instance.
|
||||
#
|
||||
# === Examples
|
||||
#
|
||||
# # Adding new parameters to be permitted in the `sign_up` action.
|
||||
# devise_parameter_sanitizer.permit(:sign_up, keys: [:subscribe_newsletter])
|
||||
#
|
||||
# # Removing the `password` parameter from the `account_update` action.
|
||||
# devise_parameter_sanitizer.permit(:account_update, except: [:password])
|
||||
#
|
||||
# # Using the block form to completely override how we permit the
|
||||
# # parameters for the `sign_up` action.
|
||||
# devise_parameter_sanitizer.permit(:sign_up) do |user|
|
||||
# user.permit(:email, :password, :password_confirmation)
|
||||
# end
|
||||
#
|
||||
#
|
||||
# Returns nothing.
|
||||
def permit(action, keys: nil, except: nil, &block)
|
||||
if block_given?
|
||||
@permitted[action] = block
|
||||
end
|
||||
|
||||
if keys.present?
|
||||
@permitted[action] ||= @auth_keys.dup
|
||||
@permitted[action].concat(keys)
|
||||
end
|
||||
|
||||
if except.present?
|
||||
@permitted[action] ||= @auth_keys.dup
|
||||
@permitted[action] = @permitted[action] - except
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def default_for(kind)
|
||||
raise ArgumentError, "a block is expected in Devise base sanitizer"
|
||||
end
|
||||
|
||||
def default_sanitize(kind)
|
||||
default_params
|
||||
# Cast a sanitized +ActionController::Parameters+ to a +HashWithIndifferentAccess+
|
||||
# that can be used elsewhere.
|
||||
#
|
||||
# Returns an +ActiveSupport::HashWithIndifferentAccess+.
|
||||
def cast_to_hash(params)
|
||||
# TODO: Remove the `with_indifferent_access` method call when we only support Rails 5+.
|
||||
params && params.to_h.with_indifferent_access
|
||||
end
|
||||
|
||||
def default_params
|
||||
params.fetch(resource_name, {})
|
||||
end
|
||||
end
|
||||
|
||||
class ParameterSanitizer < BaseSanitizer
|
||||
def initialize(*)
|
||||
super
|
||||
@permitted = Hash.new { |h,k| h[k] = attributes_for(k) }
|
||||
end
|
||||
|
||||
def sign_in
|
||||
default_params.permit self.for(:sign_in)
|
||||
end
|
||||
|
||||
def sign_up
|
||||
default_params.permit self.for(:sign_up)
|
||||
end
|
||||
|
||||
def account_update
|
||||
default_params.permit self.for(:account_update)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Change for(kind) to return the values in the @permitted
|
||||
# hash, allowing the developer to customize at runtime.
|
||||
def default_for(kind)
|
||||
@permitted[kind] || raise("No sanitizer provided for #{kind}")
|
||||
end
|
||||
|
||||
def default_sanitize(kind)
|
||||
if respond_to?(kind, true)
|
||||
send(kind)
|
||||
if hashable_resource_params?
|
||||
@params.fetch(@resource_name)
|
||||
else
|
||||
raise NotImplementedError, "Devise doesn't know how to sanitize parameters for #{kind}"
|
||||
empty_params
|
||||
end
|
||||
end
|
||||
|
||||
def attributes_for(kind)
|
||||
case kind
|
||||
when :sign_in
|
||||
auth_keys + [:password, :remember_me]
|
||||
when :sign_up
|
||||
auth_keys + [:password, :password_confirmation]
|
||||
when :account_update
|
||||
auth_keys + [:password, :password_confirmation, :current_password]
|
||||
end
|
||||
def hashable_resource_params?
|
||||
@params[@resource_name].respond_to?(:permit)
|
||||
end
|
||||
|
||||
def auth_keys
|
||||
@auth_keys ||= @resource_class.authentication_keys.respond_to?(:keys) ?
|
||||
@resource_class.authentication_keys.keys : @resource_class.authentication_keys
|
||||
def empty_params
|
||||
ActionController::Parameters.new({})
|
||||
end
|
||||
|
||||
def permit_keys(parameters, keys)
|
||||
parameters.permit(*keys)
|
||||
end
|
||||
|
||||
def extract_auth_keys(klass)
|
||||
auth_keys = klass.authentication_keys
|
||||
|
||||
auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys
|
||||
end
|
||||
|
||||
def unknown_action!(action)
|
||||
raise NotImplementedError, <<-MESSAGE.strip_heredoc
|
||||
"Devise doesn't know how to sanitize parameters for '#{action}'".
|
||||
If you want to define a new set of parameters to be sanitized use the
|
||||
`permit` method first:
|
||||
|
||||
devise_parameter_sanitizer.permit(:#{action}, keys: [:param1, :param2, :param3])
|
||||
MESSAGE
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'devise/rails/routes'
|
||||
require 'devise/rails/warden_compat'
|
||||
|
||||
@@ -11,13 +13,15 @@ module Devise
|
||||
end
|
||||
|
||||
# Force routes to be loaded if we are doing any eager load.
|
||||
config.before_eager_load { |app| app.reload_routes! }
|
||||
config.before_eager_load do |app|
|
||||
app.reload_routes! if Devise.reload_routes
|
||||
end
|
||||
|
||||
initializer "devise.url_helpers" do
|
||||
Devise.include_helpers(Devise::Controllers)
|
||||
end
|
||||
|
||||
initializer "devise.omniauth" do |app|
|
||||
initializer "devise.omniauth", after: :load_config_initializers, before: :build_middleware_stack do |app|
|
||||
Devise.omniauth_configs.each do |provider, config|
|
||||
app.middleware.use config.strategy_class, *config.args do |strategy|
|
||||
config.strategy = strategy
|
||||
@@ -29,22 +33,15 @@ module Devise
|
||||
end
|
||||
end
|
||||
|
||||
initializer "devise.secret_key" do
|
||||
initializer "devise.secret_key" do |app|
|
||||
Devise.secret_key ||= Devise::SecretKeyFinder.new(app).find
|
||||
|
||||
Devise.token_generator ||=
|
||||
if secret_key = Devise.secret_key
|
||||
Devise::TokenGenerator.new(
|
||||
Devise::CachingKeyGenerator.new(Devise::KeyGenerator.new(secret_key))
|
||||
ActiveSupport::CachingKeyGenerator.new(ActiveSupport::KeyGenerator.new(secret_key))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
initializer "devise.fix_routes_proxy_missing_respond_to_bug" do
|
||||
# Deprecate: Remove once we move to Rails 4 only.
|
||||
ActionDispatch::Routing::RoutesProxy.class_eval do
|
||||
def respond_to?(method, include_private = false)
|
||||
super || routes.url_helpers.respond_to?(method)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "active_support/core_ext/object/try"
|
||||
require "active_support/core_ext/hash/slice"
|
||||
|
||||
module ActionDispatch::Routing
|
||||
class RouteSet #:nodoc:
|
||||
# Ensure Devise modules are included only after loading routes, because we
|
||||
# need devise_for mappings already declared to create filters and helpers.
|
||||
def finalize_with_devise!
|
||||
result = finalize_without_devise!
|
||||
|
||||
module Devise
|
||||
module RouteSet
|
||||
def finalize!
|
||||
result = super
|
||||
@devise_finalized ||= begin
|
||||
if Devise.router_name.nil? && defined?(@devise_finalized) && self != Rails.application.try(:routes)
|
||||
warn "[DEVISE] We have detected that you are using devise_for inside engine routes. " \
|
||||
@@ -21,10 +20,16 @@ module ActionDispatch::Routing
|
||||
Devise.regenerate_helpers!
|
||||
true
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
alias_method_chain :finalize!, :devise
|
||||
end
|
||||
end
|
||||
|
||||
module ActionDispatch::Routing
|
||||
class RouteSet #:nodoc:
|
||||
# Ensure Devise modules are included only after loading routes, because we
|
||||
# need devise_for mappings already declared to create filters and helpers.
|
||||
prepend Devise::RouteSet
|
||||
end
|
||||
|
||||
class Mapper
|
||||
@@ -43,104 +48,132 @@ module ActionDispatch::Routing
|
||||
# needed routes:
|
||||
#
|
||||
# # Session routes for Authenticatable (default)
|
||||
# new_user_session GET /users/sign_in {:controller=>"devise/sessions", :action=>"new"}
|
||||
# user_session POST /users/sign_in {:controller=>"devise/sessions", :action=>"create"}
|
||||
# destroy_user_session DELETE /users/sign_out {:controller=>"devise/sessions", :action=>"destroy"}
|
||||
# new_user_session GET /users/sign_in {controller:"devise/sessions", action:"new"}
|
||||
# user_session POST /users/sign_in {controller:"devise/sessions", action:"create"}
|
||||
# destroy_user_session DELETE /users/sign_out {controller:"devise/sessions", action:"destroy"}
|
||||
#
|
||||
# # Password routes for Recoverable, if User model has :recoverable configured
|
||||
# new_user_password GET /users/password/new(.:format) {:controller=>"devise/passwords", :action=>"new"}
|
||||
# edit_user_password GET /users/password/edit(.:format) {:controller=>"devise/passwords", :action=>"edit"}
|
||||
# user_password PUT /users/password(.:format) {:controller=>"devise/passwords", :action=>"update"}
|
||||
# POST /users/password(.:format) {:controller=>"devise/passwords", :action=>"create"}
|
||||
# new_user_password GET /users/password/new(.:format) {controller:"devise/passwords", action:"new"}
|
||||
# edit_user_password GET /users/password/edit(.:format) {controller:"devise/passwords", action:"edit"}
|
||||
# user_password PUT /users/password(.:format) {controller:"devise/passwords", action:"update"}
|
||||
# POST /users/password(.:format) {controller:"devise/passwords", action:"create"}
|
||||
#
|
||||
# # Confirmation routes for Confirmable, if User model has :confirmable configured
|
||||
# new_user_confirmation GET /users/confirmation/new(.:format) {:controller=>"devise/confirmations", :action=>"new"}
|
||||
# user_confirmation GET /users/confirmation(.:format) {:controller=>"devise/confirmations", :action=>"show"}
|
||||
# POST /users/confirmation(.:format) {:controller=>"devise/confirmations", :action=>"create"}
|
||||
# new_user_confirmation GET /users/confirmation/new(.:format) {controller:"devise/confirmations", action:"new"}
|
||||
# user_confirmation GET /users/confirmation(.:format) {controller:"devise/confirmations", action:"show"}
|
||||
# POST /users/confirmation(.:format) {controller:"devise/confirmations", action:"create"}
|
||||
#
|
||||
# ==== Routes integration
|
||||
#
|
||||
# +devise_for+ is meant to play nicely with other routes methods. For example,
|
||||
# by calling +devise_for+ inside a namespace, it automatically nests your devise
|
||||
# controllers:
|
||||
#
|
||||
# namespace :publisher do
|
||||
# devise_for :account
|
||||
# end
|
||||
#
|
||||
# The snippet above will use publisher/sessions controller instead of devise/sessions
|
||||
# controller. You can revert this change or configure it directly by passing the :module
|
||||
# option described below to +devise_for+.
|
||||
#
|
||||
# Also note that when you use a namespace it will affect all the helpers and methods
|
||||
# for controllers and views. For example, using the above setup you'll end with
|
||||
# following methods: current_publisher_account, authenticate_publisher_account!,
|
||||
# publisher_account_signed_in, etc.
|
||||
#
|
||||
# The only aspect not affect by the router configuration is the model name. The
|
||||
# model name can be explicitly set via the :class_name option.
|
||||
#
|
||||
# ==== Options
|
||||
#
|
||||
# You can configure your routes with some options:
|
||||
#
|
||||
# * :class_name => setup a different class to be looked up by devise, if it cannot be
|
||||
# * class_name: set up a different class to be looked up by devise, if it cannot be
|
||||
# properly found by the route name.
|
||||
#
|
||||
# devise_for :users, :class_name => 'Account'
|
||||
# devise_for :users, class_name: 'Account'
|
||||
#
|
||||
# * :path => allows you to setup path name that will be used, as rails routes does.
|
||||
# The following route configuration would setup your route as /accounts instead of /users:
|
||||
# * path: allows you to set up path name that will be used, as rails routes does.
|
||||
# The following route configuration would set up your route as /accounts instead of /users:
|
||||
#
|
||||
# devise_for :users, :path => 'accounts'
|
||||
# devise_for :users, path: 'accounts'
|
||||
#
|
||||
# * :singular => setup the singular name for the given resource. This is used as the instance variable
|
||||
# name in controller, as the name in routes and the scope given to warden.
|
||||
# * singular: set up the singular name for the given resource. This is used as the helper methods
|
||||
# names in controller ("authenticate_#{singular}!", "#{singular}_signed_in?", "current_#{singular}"
|
||||
# and "#{singular}_session"), as the scope name in routes and as the scope given to warden.
|
||||
#
|
||||
# devise_for :users, :singular => :user
|
||||
# devise_for :admins, singular: :manager
|
||||
#
|
||||
# * :path_names => configure different path names to overwrite defaults :sign_in, :sign_out, :sign_up,
|
||||
# devise_scope :manager do
|
||||
# ...
|
||||
# end
|
||||
#
|
||||
# class ManagerController < ApplicationController
|
||||
# before_action authenticate_manager!
|
||||
#
|
||||
# def show
|
||||
# @manager = current_manager
|
||||
# ...
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# * path_names: configure different path names to overwrite defaults :sign_in, :sign_out, :sign_up,
|
||||
# :password, :confirmation, :unlock.
|
||||
#
|
||||
# devise_for :users, :path_names => { :sign_in => 'login', :sign_out => 'logout',
|
||||
# :password => 'secret', :confirmation => 'verification', registration: 'register }
|
||||
# devise_for :users, path_names: {
|
||||
# sign_in: 'login', sign_out: 'logout',
|
||||
# password: 'secret', confirmation: 'verification',
|
||||
# registration: 'register', edit: 'edit/profile'
|
||||
# }
|
||||
#
|
||||
# * :controllers => the controller which should be used. All routes by default points to Devise controllers.
|
||||
# * controllers: the controller which should be used. All routes by default points to Devise controllers.
|
||||
# However, if you want them to point to custom controller, you should do:
|
||||
#
|
||||
# devise_for :users, :controllers => { :sessions => "users/sessions" }
|
||||
# devise_for :users, controllers: { sessions: "users/sessions" }
|
||||
#
|
||||
# * :failure_app => a rack app which is invoked whenever there is a failure. Strings representing a given
|
||||
# * failure_app: a rack app which is invoked whenever there is a failure. Strings representing a given
|
||||
# are also allowed as parameter.
|
||||
#
|
||||
# * :sign_out_via => the HTTP method(s) accepted for the :sign_out action (default: :get),
|
||||
# * sign_out_via: the HTTP method(s) accepted for the :sign_out action (default: :delete),
|
||||
# if you wish to restrict this to accept only :post or :delete requests you should do:
|
||||
#
|
||||
# devise_for :users, :sign_out_via => [ :post, :delete ]
|
||||
# devise_for :users, sign_out_via: [:get, :post]
|
||||
#
|
||||
# You need to make sure that your sign_out controls trigger a request with a matching HTTP method.
|
||||
#
|
||||
# * :module => the namespace to find controllers (default: "devise", thus
|
||||
# * module: the namespace to find controllers (default: "devise", thus
|
||||
# accessing devise/sessions, devise/registrations, and so on). If you want
|
||||
# to namespace all at once, use module:
|
||||
#
|
||||
# devise_for :users, :module => "users"
|
||||
# devise_for :users, module: "users"
|
||||
#
|
||||
# Notice that whenever you use namespace in the router DSL, it automatically sets the module.
|
||||
# So the following setup:
|
||||
# * skip: tell which controller you want to skip routes from being created.
|
||||
# It accepts :all as an option, meaning it will not generate any route at all:
|
||||
#
|
||||
# namespace :publisher do
|
||||
# devise_for :account
|
||||
# end
|
||||
# devise_for :users, skip: :sessions
|
||||
#
|
||||
# Will use publisher/sessions controller instead of devise/sessions controller. You can revert
|
||||
# this by providing the :module option to devise_for.
|
||||
# * only: the opposite of :skip, tell which controllers only to generate routes to:
|
||||
#
|
||||
# Also pay attention that when you use a namespace it will affect all the helpers and methods for controllers
|
||||
# and views. For example, using the above setup you'll end with following methods:
|
||||
# current_publisher_account, authenticate_publisher_account!, publisher_account_signed_in, etc.
|
||||
# devise_for :users, only: :sessions
|
||||
#
|
||||
# * :skip => tell which controller you want to skip routes from being created:
|
||||
#
|
||||
# devise_for :users, :skip => :sessions
|
||||
#
|
||||
# * :only => the opposite of :skip, tell which controllers only to generate routes to:
|
||||
#
|
||||
# devise_for :users, :only => :sessions
|
||||
#
|
||||
# * :skip_helpers => skip generating Devise url helpers like new_session_path(@user).
|
||||
# * skip_helpers: skip generating Devise url helpers like new_session_path(@user).
|
||||
# This is useful to avoid conflicts with previous routes and is false by default.
|
||||
# It accepts true as option, meaning it will skip all the helpers for the controllers
|
||||
# given in :skip but it also accepts specific helpers to be skipped:
|
||||
#
|
||||
# devise_for :users, :skip => [:registrations, :confirmations], :skip_helpers => true
|
||||
# devise_for :users, :skip_helpers => [:registrations, :confirmations]
|
||||
# devise_for :users, skip: [:registrations, :confirmations], skip_helpers: true
|
||||
# devise_for :users, skip_helpers: [:registrations, :confirmations]
|
||||
#
|
||||
# * :format => include "(.:format)" in the generated routes? true by default, set to false to disable:
|
||||
# * format: include "(.:format)" in the generated routes? true by default, set to false to disable:
|
||||
#
|
||||
# devise_for :users, :format => false
|
||||
# devise_for :users, format: false
|
||||
#
|
||||
# * :constraints => works the same as Rails' constraints
|
||||
# * constraints: works the same as Rails' constraints
|
||||
#
|
||||
# * :defaults => works the same as Rails' defaults
|
||||
# * defaults: works the same as Rails' defaults
|
||||
#
|
||||
# * router_name: allows application level router name to be overwritten for the current scope
|
||||
#
|
||||
# ==== Scoping
|
||||
#
|
||||
@@ -162,7 +195,7 @@ module ActionDispatch::Routing
|
||||
#
|
||||
# class ApplicationController < ActionController::Base
|
||||
# def self.default_url_options
|
||||
# { :locale => I18n.locale }
|
||||
# { locale: I18n.locale }
|
||||
# end
|
||||
# end
|
||||
#
|
||||
@@ -187,7 +220,7 @@ module ActionDispatch::Routing
|
||||
# In order to get Devise to recognize the deactivate action, your devise_scope entry should look like this:
|
||||
#
|
||||
# devise_scope :owner do
|
||||
# post "deactivate", :to => "registrations#deactivate", :as => "deactivate_registration"
|
||||
# post "deactivate", to: "registrations#deactivate", as: "deactivate_registration"
|
||||
# end
|
||||
#
|
||||
def devise_for(*resources)
|
||||
@@ -213,7 +246,7 @@ module ActionDispatch::Routing
|
||||
raise_no_devise_method_error!(mapping.class_name) unless mapping.to.respond_to?(:devise)
|
||||
rescue NameError => e
|
||||
raise unless mapping.class_name == resource.to_s.classify
|
||||
warn "[WARNING] You provided devise_for #{resource.inspect} but there is " <<
|
||||
warn "[WARNING] You provided devise_for #{resource.inspect} but there is " \
|
||||
"no model #{mapping.class_name} defined in your application"
|
||||
next
|
||||
rescue NoMethodError => e
|
||||
@@ -221,7 +254,14 @@ module ActionDispatch::Routing
|
||||
raise_no_devise_method_error!(mapping.class_name)
|
||||
end
|
||||
|
||||
routes = mapping.used_routes
|
||||
if options[:controllers] && options[:controllers][:omniauth_callbacks]
|
||||
unless mapping.omniauthable?
|
||||
raise ArgumentError, "Mapping omniauth_callbacks on a resource that is not omniauthable\n" \
|
||||
"Please add `devise :omniauthable` to the `#{mapping.class_name}` model"
|
||||
end
|
||||
end
|
||||
|
||||
routes = mapping.used_routes
|
||||
|
||||
devise_scope mapping.name do
|
||||
with_devise_exclusive_scope mapping.fullpath, mapping.name, options do
|
||||
@@ -244,7 +284,7 @@ module ActionDispatch::Routing
|
||||
# end
|
||||
#
|
||||
# authenticate :user, lambda {|u| u.role == "admin"} do
|
||||
# root :to => "admin/dashboard#show", :as => :user_root
|
||||
# root to: "admin/dashboard#show", as: :user_root
|
||||
# end
|
||||
#
|
||||
def authenticate(scope=nil, block=nil)
|
||||
@@ -258,18 +298,18 @@ module ActionDispatch::Routing
|
||||
# a model and allows extra constraints to be done on the instance.
|
||||
#
|
||||
# authenticated :admin do
|
||||
# root :to => 'admin/dashboard#show', :as => :admin_root
|
||||
# root to: 'admin/dashboard#show', as: :admin_root
|
||||
# end
|
||||
#
|
||||
# authenticated do
|
||||
# root :to => 'dashboard#show', :as => :authenticated_root
|
||||
# root to: 'dashboard#show', as: :authenticated_root
|
||||
# end
|
||||
#
|
||||
# authenticated :user, lambda {|u| u.role == "admin"} do
|
||||
# root :to => "admin/dashboard#show", :as => :user_root
|
||||
# root to: "admin/dashboard#show", as: :user_root
|
||||
# end
|
||||
#
|
||||
# root :to => 'landing#show'
|
||||
# root to: 'landing#show'
|
||||
#
|
||||
def authenticated(scope=nil, block=nil)
|
||||
constraints_for(:authenticate?, scope, block) do
|
||||
@@ -282,15 +322,15 @@ module ActionDispatch::Routing
|
||||
#
|
||||
# unauthenticated do
|
||||
# as :user do
|
||||
# root :to => 'devise/registrations#new'
|
||||
# root to: 'devise/registrations#new'
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# root :to => 'dashboard#show'
|
||||
# root to: 'dashboard#show'
|
||||
#
|
||||
def unauthenticated(scope=nil)
|
||||
constraint = lambda do |request|
|
||||
not request.env["warden"].authenticate? :scope => scope
|
||||
not request.env["warden"].authenticate? scope: scope
|
||||
end
|
||||
|
||||
constraints(constraint) do
|
||||
@@ -300,10 +340,10 @@ module ActionDispatch::Routing
|
||||
|
||||
# Sets the devise scope to be used in the controller. If you have custom routes,
|
||||
# you are required to call this method (also aliased as :as) in order to specify
|
||||
# to which controller it is targetted.
|
||||
# to which controller it is targeted.
|
||||
#
|
||||
# as :user do
|
||||
# get "sign_in", :to => "devise/sessions#new"
|
||||
# get "sign_in", to: "devise/sessions#new"
|
||||
# end
|
||||
#
|
||||
# Notice you cannot have two scopes mapping to the same URL. And remember, if
|
||||
@@ -335,41 +375,42 @@ module ActionDispatch::Routing
|
||||
protected
|
||||
|
||||
def devise_session(mapping, controllers) #:nodoc:
|
||||
resource :session, :only => [], :controller => controllers[:sessions], :path => "" do
|
||||
get :new, :path => mapping.path_names[:sign_in], :as => "new"
|
||||
post :create, :path => mapping.path_names[:sign_in]
|
||||
match :destroy, :path => mapping.path_names[:sign_out], :as => "destroy", :via => mapping.sign_out_via
|
||||
resource :session, only: [], controller: controllers[:sessions], path: "" do
|
||||
get :new, path: mapping.path_names[:sign_in], as: "new"
|
||||
post :create, path: mapping.path_names[:sign_in]
|
||||
match :destroy, path: mapping.path_names[:sign_out], as: "destroy", via: mapping.sign_out_via
|
||||
end
|
||||
end
|
||||
|
||||
def devise_password(mapping, controllers) #:nodoc:
|
||||
resource :password, :only => [:new, :create, :edit, :update],
|
||||
:path => mapping.path_names[:password], :controller => controllers[:passwords]
|
||||
resource :password, only: [:new, :create, :edit, :update],
|
||||
path: mapping.path_names[:password], controller: controllers[:passwords]
|
||||
end
|
||||
|
||||
def devise_confirmation(mapping, controllers) #:nodoc:
|
||||
resource :confirmation, :only => [:new, :create, :show],
|
||||
:path => mapping.path_names[:confirmation], :controller => controllers[:confirmations]
|
||||
resource :confirmation, only: [:new, :create, :show],
|
||||
path: mapping.path_names[:confirmation], controller: controllers[:confirmations]
|
||||
end
|
||||
|
||||
def devise_unlock(mapping, controllers) #:nodoc:
|
||||
if mapping.to.unlock_strategy_enabled?(:email)
|
||||
resource :unlock, :only => [:new, :create, :show],
|
||||
:path => mapping.path_names[:unlock], :controller => controllers[:unlocks]
|
||||
resource :unlock, only: [:new, :create, :show],
|
||||
path: mapping.path_names[:unlock], controller: controllers[:unlocks]
|
||||
end
|
||||
end
|
||||
|
||||
def devise_registration(mapping, controllers) #:nodoc:
|
||||
path_names = {
|
||||
:new => mapping.path_names[:sign_up],
|
||||
:cancel => mapping.path_names[:cancel]
|
||||
new: mapping.path_names[:sign_up],
|
||||
edit: mapping.path_names[:edit],
|
||||
cancel: mapping.path_names[:cancel]
|
||||
}
|
||||
|
||||
options = {
|
||||
:only => [:new, :create, :edit, :update, :destroy],
|
||||
:path => mapping.path_names[:registration],
|
||||
:path_names => path_names,
|
||||
:controller => controllers[:registrations]
|
||||
only: [:new, :create, :edit, :update, :destroy],
|
||||
path: mapping.path_names[:registration],
|
||||
path_names: path_names,
|
||||
controller: controllers[:registrations]
|
||||
}
|
||||
|
||||
resource :registration, options do
|
||||
@@ -378,45 +419,64 @@ module ActionDispatch::Routing
|
||||
end
|
||||
|
||||
def devise_omniauth_callback(mapping, controllers) #:nodoc:
|
||||
path, @scope[:path] = @scope[:path], nil
|
||||
path_prefix = Devise.omniauth_path_prefix || "/#{mapping.path}/auth".squeeze("/")
|
||||
if mapping.fullpath =~ /:[a-zA-Z_]/
|
||||
raise <<-ERROR
|
||||
Devise does not support scoping OmniAuth callbacks under a dynamic segment
|
||||
and you have set #{mapping.fullpath.inspect}. You can work around by passing
|
||||
`skip: :omniauth_callbacks` to the `devise_for` call and extract omniauth
|
||||
options to another `devise_for` call outside the scope. Here is an example:
|
||||
|
||||
devise_for :users, only: :omniauth_callbacks, controllers: {omniauth_callbacks: 'users/omniauth_callbacks'}
|
||||
|
||||
scope '/(:locale)', locale: /ru|en/ do
|
||||
devise_for :users, skip: :omniauth_callbacks
|
||||
end
|
||||
ERROR
|
||||
end
|
||||
current_scope = @scope.dup
|
||||
if @scope.respond_to? :new
|
||||
@scope = @scope.new path: nil
|
||||
else
|
||||
@scope[:path] = nil
|
||||
end
|
||||
path_prefix = Devise.omniauth_path_prefix || "/#{mapping.fullpath}/auth".squeeze("/")
|
||||
|
||||
set_omniauth_path_prefix!(path_prefix)
|
||||
|
||||
providers = Regexp.union(mapping.to.omniauth_providers.map(&:to_s))
|
||||
mapping.to.omniauth_providers.each do |provider|
|
||||
match "#{path_prefix}/#{provider}",
|
||||
to: "#{controllers[:omniauth_callbacks]}#passthru",
|
||||
as: "#{provider}_omniauth_authorize",
|
||||
via: [:get, :post]
|
||||
|
||||
match "#{path_prefix}/:provider",
|
||||
:constraints => { :provider => providers },
|
||||
:to => "#{controllers[:omniauth_callbacks]}#passthru",
|
||||
:as => :omniauth_authorize,
|
||||
:via => [:get, :post]
|
||||
|
||||
match "#{path_prefix}/:action/callback",
|
||||
:constraints => { :action => providers },
|
||||
:to => controllers[:omniauth_callbacks],
|
||||
:as => :omniauth_callback,
|
||||
:via => [:get, :post]
|
||||
match "#{path_prefix}/#{provider}/callback",
|
||||
to: "#{controllers[:omniauth_callbacks]}##{provider}",
|
||||
as: "#{provider}_omniauth_callback",
|
||||
via: [:get, :post]
|
||||
end
|
||||
ensure
|
||||
@scope[:path] = path
|
||||
@scope = current_scope
|
||||
end
|
||||
|
||||
DEVISE_SCOPE_KEYS = [:as, :path, :module, :constraints, :defaults, :options]
|
||||
|
||||
def with_devise_exclusive_scope(new_path, new_as, options) #:nodoc:
|
||||
old = {}
|
||||
DEVISE_SCOPE_KEYS.each { |k| old[k] = @scope[k] }
|
||||
current_scope = @scope.dup
|
||||
|
||||
new = { :as => new_as, :path => new_path, :module => nil }
|
||||
new.merge!(options.slice(:constraints, :defaults, :options))
|
||||
exclusive = { as: new_as, path: new_path, module: nil }
|
||||
exclusive.merge!(options.slice(:constraints, :defaults, :options))
|
||||
|
||||
@scope.merge!(new)
|
||||
if @scope.respond_to? :new
|
||||
@scope = @scope.new exclusive
|
||||
else
|
||||
exclusive.each_pair { |key, value| @scope[key] = value }
|
||||
end
|
||||
yield
|
||||
ensure
|
||||
@scope.merge!(old)
|
||||
@scope = current_scope
|
||||
end
|
||||
|
||||
def constraints_for(method_to_apply, scope=nil, block=nil)
|
||||
constraint = lambda do |request|
|
||||
request.env['warden'].send(method_to_apply, :scope => scope) &&
|
||||
request.env['warden'].send(method_to_apply, scope: scope) &&
|
||||
(block.nil? || block.call(request.env["warden"].user(scope)))
|
||||
end
|
||||
|
||||
@@ -442,6 +502,7 @@ Devise.secret_key was not set. Please add the following to your Devise initializ
|
||||
|
||||
config.secret_key = '#{SecureRandom.hex(64)}'
|
||||
|
||||
Please ensure you restarted your application after installing Devise or setting the key.
|
||||
ERROR
|
||||
end
|
||||
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Warden::Mixins::Common
|
||||
def request
|
||||
@request ||= ActionDispatch::Request.new(env)
|
||||
end
|
||||
|
||||
# Deprecate: Remove this check once we move to Rails 4 only.
|
||||
NULL_STORE =
|
||||
defined?(ActionController::RequestForgeryProtection::ProtectionMethods::NullSession::NullSessionHash) ?
|
||||
ActionController::RequestForgeryProtection::ProtectionMethods::NullSession::NullSessionHash : nil
|
||||
|
||||
def reset_session!
|
||||
# Calling reset_session on NULL_STORE causes it fail.
|
||||
# This is a bug that needs to be fixed in Rails.
|
||||
unless NULL_STORE && request.session.is_a?(NULL_STORE)
|
||||
request.reset_session
|
||||
end
|
||||
request.reset_session
|
||||
end
|
||||
|
||||
def cookies
|
||||
|
||||
27
lib/devise/secret_key_finder.rb
Normal file
27
lib/devise/secret_key_finder.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
class SecretKeyFinder
|
||||
def initialize(application)
|
||||
@application = application
|
||||
end
|
||||
|
||||
def find
|
||||
if @application.respond_to?(:credentials) && key_exists?(@application.credentials)
|
||||
@application.credentials.secret_key_base
|
||||
elsif @application.respond_to?(:secrets) && key_exists?(@application.secrets)
|
||||
@application.secrets.secret_key_base
|
||||
elsif @application.config.respond_to?(:secret_key_base) && key_exists?(@application.config)
|
||||
@application.config.secret_key_base
|
||||
elsif @application.respond_to?(:secret_key_base) && key_exists?(@application)
|
||||
@application.secret_key_base
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def key_exists?(object)
|
||||
object.secret_key_base.present?
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'devise/strategies/base'
|
||||
|
||||
module Devise
|
||||
@@ -16,11 +18,18 @@ module Devise
|
||||
valid_for_params_auth? || valid_for_http_auth?
|
||||
end
|
||||
|
||||
# Override and set to false for things like OmniAuth that technically
|
||||
# run through Authentication (user_set) very often, which would normally
|
||||
# reset CSRF data in the session
|
||||
def clean_up_csrf?
|
||||
true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Receives a resource and check if it is valid by calling valid_for_authentication?
|
||||
# An optional block that will be triggered while validating can be optionally
|
||||
# given as parameter. Check Devise::Models::Authenticable.valid_for_authentication?
|
||||
# A block that will be triggered while validating can be optionally
|
||||
# given as parameter. Check Devise::Models::Authenticatable.valid_for_authentication?
|
||||
# for more information.
|
||||
#
|
||||
# In case the resource can't be validated, it will fail with the given
|
||||
@@ -29,7 +38,6 @@ module Devise
|
||||
result = resource && resource.valid_for_authentication?(&block)
|
||||
|
||||
if result
|
||||
decorate(resource)
|
||||
true
|
||||
else
|
||||
if resource
|
||||
@@ -40,7 +48,7 @@ module Devise
|
||||
end
|
||||
|
||||
# Get values from params and set in the resource.
|
||||
def decorate(resource)
|
||||
def remember_me(resource)
|
||||
resource.remember_me = remember_me? if resource.respond_to?(:remember_me=)
|
||||
end
|
||||
|
||||
@@ -49,9 +57,9 @@ module Devise
|
||||
valid_params? && Devise::TRUE_VALUES.include?(params_auth_hash[:remember_me])
|
||||
end
|
||||
|
||||
# Check if this is strategy is valid for http authentication by:
|
||||
# Check if this is a valid strategy for http authentication by:
|
||||
#
|
||||
# * Validating if the model allows params authentication;
|
||||
# * Validating if the model allows http authentication;
|
||||
# * If any of the authorization headers were sent;
|
||||
# * If all authentication keys are present;
|
||||
#
|
||||
@@ -59,7 +67,7 @@ module Devise
|
||||
http_authenticatable? && request.authorization && with_authentication_hash(:http_auth, http_auth_hash)
|
||||
end
|
||||
|
||||
# Check if this is strategy is valid for params authentication by:
|
||||
# Check if this is a valid strategy for params authentication by:
|
||||
#
|
||||
# * Validating if the model allows params authentication;
|
||||
# * If the request hits the sessions controller through POST;
|
||||
@@ -102,14 +110,17 @@ module Devise
|
||||
params_auth_hash.is_a?(Hash)
|
||||
end
|
||||
|
||||
# Check if password is present and is not equal to "X" (default value for token).
|
||||
# Note: unlike `Model.valid_password?`, this method does not actually
|
||||
# ensure that the password in the params matches the password stored in
|
||||
# the database. It only checks if the password is *present*. Do not rely
|
||||
# on this method for validating that a given password is correct.
|
||||
def valid_password?
|
||||
password.present? && password != "X"
|
||||
password.present?
|
||||
end
|
||||
|
||||
# Helper to decode credentials from HTTP.
|
||||
def decode_credentials
|
||||
return [] unless request.authorization && request.authorization =~ /^Basic (.*)/m
|
||||
return [] unless request.authorization && request.authorization =~ /^Basic (.*)/mi
|
||||
Base64.decode64($1).split(/:/, 2)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Strategies
|
||||
# Base strategy for Devise. Responsible for verifying correct scope and mapping.
|
||||
@@ -17,4 +19,4 @@ module Devise
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,17 +1,28 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'devise/strategies/authenticatable'
|
||||
|
||||
module Devise
|
||||
module Strategies
|
||||
# Default strategy for signing in a user, based on his email and password in the database.
|
||||
# Default strategy for signing in a user, based on their email and password in the database.
|
||||
class DatabaseAuthenticatable < Authenticatable
|
||||
def authenticate!
|
||||
resource = valid_password? && mapping.to.find_for_database_authentication(authentication_hash)
|
||||
return fail(:not_found_in_database) unless resource
|
||||
resource = password.present? && mapping.to.find_for_database_authentication(authentication_hash)
|
||||
hashed = false
|
||||
|
||||
if validate(resource){ resource.valid_password?(password) }
|
||||
if validate(resource){ hashed = true; resource.valid_password?(password) }
|
||||
remember_me(resource)
|
||||
resource.after_database_authentication
|
||||
success!(resource)
|
||||
end
|
||||
|
||||
# In paranoid mode, hash the password even when a resource doesn't exist for the given authentication key.
|
||||
# This is necessary to prevent enumeration attacks - e.g. the request is faster when a resource doesn't
|
||||
# exist in the database if the password hashing algorithm is not called.
|
||||
mapping.to.new.password = password if !hashed && Devise.paranoid
|
||||
unless resource
|
||||
Devise.paranoid ? fail(:invalid) : fail(:not_found_in_database)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'devise/strategies/authenticatable'
|
||||
|
||||
module Devise
|
||||
@@ -25,15 +27,25 @@ module Devise
|
||||
end
|
||||
|
||||
if validate(resource)
|
||||
remember_me(resource) if extend_remember_me?(resource)
|
||||
resource.after_remembered
|
||||
success!(resource)
|
||||
end
|
||||
end
|
||||
|
||||
# No need to clean up the CSRF when using rememberable.
|
||||
# In fact, cleaning it up here would be a bug because
|
||||
# rememberable is triggered on GET requests which means
|
||||
# we would render a page on first access with all csrf
|
||||
# tokens expired.
|
||||
def clean_up_csrf?
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def decorate(resource)
|
||||
super
|
||||
resource.extend_remember_period = mapping.to.extend_remember_period if resource.respond_to?(:extend_remember_period=)
|
||||
def extend_remember_me?(resource)
|
||||
resource.respond_to?(:extend_remember_period) && resource.extend_remember_period
|
||||
end
|
||||
|
||||
def remember_me?
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
require 'devise/strategies/base'
|
||||
|
||||
module Devise
|
||||
module Strategies
|
||||
# Strategy for signing in a user, based on a authenticatable token. This works for both params
|
||||
# and http. For the former, all you need to do is to pass the params in the URL:
|
||||
#
|
||||
# http://myapp.example.com/?user_token=SECRET
|
||||
#
|
||||
# For headers, you can use basic authentication passing the token as username and
|
||||
# blank password. Since some clients may require a password, you can pass "X" as
|
||||
# password and it will simply be ignored.
|
||||
#
|
||||
# You may also pass the token using the Token authentication mechanism provided
|
||||
# by Rails: http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html
|
||||
# The token options are stored in request.env['devise.token_options']
|
||||
class TokenAuthenticatable < Authenticatable
|
||||
def store?
|
||||
super && !mapping.to.skip_session_storage.include?(:token_auth)
|
||||
end
|
||||
|
||||
def valid?
|
||||
super || valid_for_token_auth?
|
||||
end
|
||||
|
||||
def authenticate!
|
||||
resource = mapping.to.find_for_token_authentication(authentication_hash)
|
||||
return fail(:invalid_token) unless resource
|
||||
|
||||
if validate(resource)
|
||||
resource.after_token_authentication
|
||||
success!(resource)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Token Authenticatable can be authenticated with params in any controller and any verb.
|
||||
def valid_params_request?
|
||||
true
|
||||
end
|
||||
|
||||
# Do not use remember_me behavior with token.
|
||||
def remember_me?
|
||||
false
|
||||
end
|
||||
|
||||
# Check if the model accepts this strategy as token authenticatable.
|
||||
def token_authenticatable?
|
||||
mapping.to.http_authenticatable?(:token_options)
|
||||
end
|
||||
|
||||
# Check if this is strategy is valid for token authentication by:
|
||||
#
|
||||
# * Validating if the model allows http token authentication;
|
||||
# * If the http auth token exists;
|
||||
# * If all authentication keys are present;
|
||||
#
|
||||
def valid_for_token_auth?
|
||||
token_authenticatable? && auth_token.present? && with_authentication_hash(:token_auth, token_auth_hash)
|
||||
end
|
||||
|
||||
# Extract the auth token from the request
|
||||
def auth_token
|
||||
@auth_token ||= ActionController::HttpAuthentication::Token.token_and_options(request)
|
||||
end
|
||||
|
||||
# Extract a hash with attributes:values from the auth_token
|
||||
def token_auth_hash
|
||||
request.env['devise.token_options'] = auth_token.last
|
||||
{ authentication_keys.first => auth_token.first }
|
||||
end
|
||||
|
||||
# Try both scoped and non scoped keys
|
||||
def params_auth_hash
|
||||
if params[scope].kind_of?(Hash) && params[scope].has_key?(authentication_keys.first)
|
||||
params[scope]
|
||||
else
|
||||
params
|
||||
end
|
||||
end
|
||||
|
||||
# Overwrite authentication keys to use token_authentication_key.
|
||||
def authentication_keys
|
||||
@authentication_keys ||= [mapping.to.token_authentication_key]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Warden::Strategies.add(:token_authenticatable, Devise::Strategies::TokenAuthenticatable)
|
||||
165
lib/devise/test/controller_helpers.rb
Normal file
165
lib/devise/test/controller_helpers.rb
Normal file
@@ -0,0 +1,165 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Test
|
||||
# `Devise::Test::ControllerHelpers` provides a facility to test controllers
|
||||
# in isolation when using `ActionController::TestCase` allowing you to
|
||||
# quickly sign_in or sign_out a user. Do not use
|
||||
# `Devise::Test::ControllerHelpers` in integration tests.
|
||||
#
|
||||
# Examples
|
||||
#
|
||||
# class PostsTest < ActionController::TestCase
|
||||
# include Devise::Test::ControllerHelpers
|
||||
#
|
||||
# test 'authenticated users can GET index' do
|
||||
# sign_in users(:bob)
|
||||
#
|
||||
# get :index
|
||||
# assert_response :success
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# Important: you should not test Warden specific behavior (like callbacks)
|
||||
# using `Devise::Test::ControllerHelpers` since it is a stub of the actual
|
||||
# behavior. Such callbacks should be tested in your integration suite instead.
|
||||
module ControllerHelpers
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
setup :setup_controller_for_warden, :warden
|
||||
end
|
||||
|
||||
# Override process to consider warden.
|
||||
def process(*)
|
||||
_catch_warden { super }
|
||||
|
||||
@response
|
||||
end
|
||||
|
||||
# We need to set up the environment variables and the response in the controller.
|
||||
def setup_controller_for_warden #:nodoc:
|
||||
@request.env['action_controller.instance'] = @controller
|
||||
end
|
||||
|
||||
# Quick access to Warden::Proxy.
|
||||
def warden #:nodoc:
|
||||
@request.env['warden'] ||= begin
|
||||
manager = Warden::Manager.new(nil) do |config|
|
||||
config.merge! Devise.warden_config
|
||||
end
|
||||
Warden::Proxy.new(@request.env, manager)
|
||||
end
|
||||
end
|
||||
|
||||
# sign_in a given resource by storing its keys in the session.
|
||||
# This method bypass any warden authentication callback.
|
||||
#
|
||||
# * +resource+ - The resource that should be authenticated
|
||||
# * +scope+ - An optional +Symbol+ with the scope where the resource
|
||||
# should be signed in with.
|
||||
# Examples:
|
||||
#
|
||||
# sign_in users(:alice)
|
||||
# sign_in users(:alice), scope: :admin
|
||||
def sign_in(resource, deprecated = nil, scope: nil)
|
||||
if deprecated.present?
|
||||
scope = resource
|
||||
resource = deprecated
|
||||
|
||||
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
|
||||
[Devise] sign_in(:#{scope}, resource) on controller tests is deprecated and will be removed from Devise.
|
||||
Please use sign_in(resource, scope: :#{scope}) instead.
|
||||
DEPRECATION
|
||||
end
|
||||
|
||||
scope ||= Devise::Mapping.find_scope!(resource)
|
||||
|
||||
warden.instance_variable_get(:@users).delete(scope)
|
||||
warden.session_serializer.store(resource, scope)
|
||||
end
|
||||
|
||||
# Sign out a given resource or scope by calling logout on Warden.
|
||||
# This method bypass any warden logout callback.
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# sign_out :user # sign_out(scope)
|
||||
# sign_out @user # sign_out(resource)
|
||||
#
|
||||
def sign_out(resource_or_scope)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
@controller.instance_variable_set(:"@current_#{scope}", nil)
|
||||
user = warden.instance_variable_get(:@users).delete(scope)
|
||||
warden.session_serializer.delete(scope, user)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Catch warden continuations and handle like the middleware would.
|
||||
# Returns nil when interrupted, otherwise the normal result of the block.
|
||||
def _catch_warden(&block)
|
||||
result = catch(:warden, &block)
|
||||
|
||||
env = @controller.request.env
|
||||
|
||||
result ||= {}
|
||||
|
||||
# Set the response. In production, the rack result is returned
|
||||
# from Warden::Manager#call, which the following is modelled on.
|
||||
case result
|
||||
when Array
|
||||
if result.first == 401 && intercept_401?(env) # does this happen during testing?
|
||||
_process_unauthenticated(env)
|
||||
else
|
||||
result
|
||||
end
|
||||
when Hash
|
||||
_process_unauthenticated(env, result)
|
||||
else
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
def _process_unauthenticated(env, options = {})
|
||||
options[:action] ||= :unauthenticated
|
||||
proxy = request.env['warden']
|
||||
result = options[:result] || proxy.result
|
||||
|
||||
ret = case result
|
||||
when :redirect
|
||||
body = proxy.message || "You are being redirected to #{proxy.headers['Location']}"
|
||||
[proxy.status, proxy.headers, [body]]
|
||||
when :custom
|
||||
proxy.custom_response
|
||||
else
|
||||
request.env["PATH_INFO"] = "/#{options[:action]}"
|
||||
request.env["warden.options"] = options
|
||||
Warden::Manager._run_callbacks(:before_failure, env, options)
|
||||
|
||||
status, headers, response = Devise.warden_config[:failure_app].call(env).to_a
|
||||
@controller.response.headers.merge!(headers)
|
||||
@controller.response.content_type = headers["Content-Type"] unless Rails::VERSION::MAJOR >= 5
|
||||
@controller.status = status
|
||||
@controller.response.body = response.body
|
||||
nil # causes process return @response
|
||||
end
|
||||
|
||||
# ensure that the controller response is set up. In production, this is
|
||||
# not necessary since warden returns the results to rack. However, at
|
||||
# testing time, we want the response to be available to the testing
|
||||
# framework to verify what would be returned to rack.
|
||||
if ret.is_a?(Array)
|
||||
status, headers, body = *ret
|
||||
# ensure the controller response is set to our response.
|
||||
@controller.response ||= @response
|
||||
@response.status = status
|
||||
@response.headers.merge!(headers)
|
||||
@response.body = body
|
||||
end
|
||||
|
||||
ret
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user