mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-09 23:58:06 -05:00
Compare commits
1894 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
08edcc10fe | ||
|
|
2d919fba32 | ||
|
|
843168d5c7 | ||
|
|
095572b6fd | ||
|
|
b9112d4308 | ||
|
|
23c5517009 | ||
|
|
32e60fade5 | ||
|
|
fc251c306c | ||
|
|
f6a74e90e5 | ||
|
|
91f2bce08e | ||
|
|
5e81210400 | ||
|
|
4b7fcac23a | ||
|
|
213ed81641 | ||
|
|
3232d14b20 | ||
|
|
949c9e5ded | ||
|
|
66c829eef4 | ||
|
|
6a22e88dfa | ||
|
|
605924a921 | ||
|
|
72c3472fe1 | ||
|
|
ea870e0636 | ||
|
|
3f00d735a4 | ||
|
|
1437ae2ce3 | ||
|
|
052cbef205 | ||
|
|
b1754074e5 | ||
|
|
e8b70bb04d | ||
|
|
58cbd91512 | ||
|
|
177ed8a356 | ||
|
|
a5e63d7a28 | ||
|
|
5ecbbdf260 | ||
|
|
efe34219a9 | ||
|
|
bc0cab8d60 | ||
|
|
7e855eddef | ||
|
|
8541c465d7 | ||
|
|
4e318b5167 | ||
|
|
5e7caffc9e | ||
|
|
87edf0fbcf | ||
|
|
e7de0d4c4c | ||
|
|
2a8d0f9bee | ||
|
|
a1d83d5d4e | ||
|
|
4681f81ce6 | ||
|
|
86f2696b84 | ||
|
|
20cf73facf | ||
|
|
d0219d914f | ||
|
|
50d17bbb8e | ||
|
|
3dccf3c6ff | ||
|
|
acd33174fc | ||
|
|
d56641f514 | ||
|
|
354e5022bf | ||
|
|
3cdbf15fe9 | ||
|
|
143794d701 | ||
|
|
4048545151 | ||
|
|
32648027e2 | ||
|
|
7e96bac6a4 | ||
|
|
f5a77ac598 | ||
|
|
591f4a97f7 | ||
|
|
cf1989e1da | ||
|
|
7c8c0f8dba | ||
|
|
66afa2a2bf | ||
|
|
747751a20f | ||
|
|
8e0327e203 | ||
|
|
d88b3cedfb | ||
|
|
9a60415e2e | ||
|
|
b861a65e72 | ||
|
|
1ab7792beb | ||
|
|
c4d5a3fdaa | ||
|
|
11a77055f1 | ||
|
|
9bc8e1211b | ||
|
|
cd1bc53947 | ||
|
|
fffbeb5cc7 | ||
|
|
7539d31a05 | ||
|
|
78fedd6c10 | ||
|
|
14a0cfefaa | ||
|
|
b7e67115fc | ||
|
|
b7bc8dec12 | ||
|
|
b8ed2f3160 | ||
|
|
b46b7e3736 | ||
|
|
c5ef39f087 | ||
|
|
cfb8228de9 | ||
|
|
4e0c598de1 | ||
|
|
fed6a92d55 | ||
|
|
2c1ca126f4 | ||
|
|
36fb1ecf4d | ||
|
|
08986dbd4b | ||
|
|
b69d2c412f | ||
|
|
6f5d176e8e | ||
|
|
57515de5ad | ||
|
|
49aebde435 | ||
|
|
bc598b9da3 | ||
|
|
da0323e591 | ||
|
|
061e9d7404 | ||
|
|
3c519b13ff | ||
|
|
aeec6138c2 | ||
|
|
75ad4ee87b | ||
|
|
e029ad7b0c | ||
|
|
225afe6813 | ||
|
|
8487637b2f | ||
|
|
8978bd4fe0 | ||
|
|
5926898cf4 | ||
|
|
df2995ce19 | ||
|
|
5717c6f082 | ||
|
|
72cf2481b5 | ||
|
|
5c39a0c6d1 | ||
|
|
56a26bd280 | ||
|
|
b194882b23 | ||
|
|
b5909f9b93 | ||
|
|
3c9cfa50c0 | ||
|
|
e632240aee | ||
|
|
176158a309 | ||
|
|
2503f2d0a8 | ||
|
|
85897b4fe2 | ||
|
|
fdd47d74db | ||
|
|
ae4448403c | ||
|
|
2ead747be6 | ||
|
|
10aadee637 | ||
|
|
7670eb8e98 | ||
|
|
486dc65884 | ||
|
|
17e85aa79d | ||
|
|
10c9a492ab | ||
|
|
b7079c7cf2 | ||
|
|
55e69b18a4 | ||
|
|
020341176c | ||
|
|
a79846730e | ||
|
|
48eea9d325 | ||
|
|
dd7c3ee91f | ||
|
|
4e2cdc2d5b | ||
|
|
545a5cec3b | ||
|
|
ab77e08690 | ||
|
|
39c1a2c7d0 | ||
|
|
270e2ece19 | ||
|
|
6b5988d756 | ||
|
|
a4efbb9ad6 | ||
|
|
eb0ad1c21a | ||
|
|
f5e33089a0 | ||
|
|
e499fadf52 | ||
|
|
70199ed039 | ||
|
|
fb07558082 | ||
|
|
5ad122b928 | ||
|
|
c78b4b40c1 | ||
|
|
ef2a2280a3 | ||
|
|
42fca4dbe5 | ||
|
|
03f2a6a5e4 | ||
|
|
cc2fea8276 | ||
|
|
bb4cc2428f | ||
|
|
43f7cf0f12 | ||
|
|
bb5d65209a | ||
|
|
69f79ad446 | ||
|
|
75fdd2944d | ||
|
|
ae48fc8419 | ||
|
|
d6d61fc5be | ||
|
|
19c8f0c0ad | ||
|
|
63627d1439 | ||
|
|
662f0e76d8 | ||
|
|
eadce2fef6 | ||
|
|
0fe0373144 | ||
|
|
1f9ebbd9f4 | ||
|
|
a0058d5fbf | ||
|
|
e8d1c9ca23 | ||
|
|
d9d5ae3d58 | ||
|
|
b51c7fe59b | ||
|
|
a6b754b697 | ||
|
|
92218e9ecc | ||
|
|
60e933df73 | ||
|
|
b451fc0aad | ||
|
|
2f28e48f54 | ||
|
|
76e4967ca1 | ||
|
|
dceb788c6b | ||
|
|
fae8e977e8 | ||
|
|
0a588fab3a | ||
|
|
bbf57214ac | ||
|
|
804fbdf6d5 | ||
|
|
e4987e8bb7 | ||
|
|
9d5a9c8a61 | ||
|
|
c8aa5f3e62 | ||
|
|
df4b282566 | ||
|
|
b8c5d76c5a | ||
|
|
b871bd5036 | ||
|
|
c439b80524 | ||
|
|
704221d48f | ||
|
|
da70348662 | ||
|
|
2e6457006e | ||
|
|
1f68309c47 | ||
|
|
c618969677 | ||
|
|
93013c2e89 | ||
|
|
8ec89bf659 | ||
|
|
b3edfeab73 | ||
|
|
c63483ae24 | ||
|
|
3ed0dc5d9f | ||
|
|
8a93c34080 | ||
|
|
2dfa7e1761 | ||
|
|
5bf4f57fcf | ||
|
|
1b8fd7c2ff | ||
|
|
f75352a373 | ||
|
|
fa5ae57ce4 | ||
|
|
ac2ebdfb11 | ||
|
|
ea94e199ce | ||
|
|
d89dad5728 | ||
|
|
32a141d2a9 | ||
|
|
36557ef641 | ||
|
|
aa24335656 | ||
|
|
1acd3d1790 | ||
|
|
d20fdf87b6 | ||
|
|
95f56258d7 | ||
|
|
8e9ad4626e | ||
|
|
2de7cbae25 | ||
|
|
37473cdaf7 | ||
|
|
bf30d79aca | ||
|
|
148fa99dce | ||
|
|
77203e3d97 | ||
|
|
b151d2cfe2 | ||
|
|
e0ffe8f85f | ||
|
|
78f137368c | ||
|
|
af4a582300 | ||
|
|
2f88f7c0ed | ||
|
|
ce37c301ff | ||
|
|
bd14589fe4 | ||
|
|
c07bc69fad | ||
|
|
9a8cb011d7 | ||
|
|
335a6af861 | ||
|
|
72cbafa322 | ||
|
|
4549d8c65f | ||
|
|
6c566c1ca4 | ||
|
|
41aed807fc | ||
|
|
ddea9359a6 | ||
|
|
5d87e150f7 | ||
|
|
d90e365636 | ||
|
|
22442907af | ||
|
|
10f58b636f | ||
|
|
2d14bd2826 | ||
|
|
f4ceecece4 | ||
|
|
359fdd840c | ||
|
|
c6578250d2 | ||
|
|
dc14c76ff6 | ||
|
|
5e74fd406b | ||
|
|
ebeee33429 | ||
|
|
e449c3b6d2 | ||
|
|
58871172ab | ||
|
|
41a2d65ade | ||
|
|
e6dc425abb | ||
|
|
d29b744d92 | ||
|
|
e79ebe8aec | ||
|
|
10f93129c3 | ||
|
|
04d9512f30 | ||
|
|
135c8da390 | ||
|
|
aca7e5d162 | ||
|
|
02298117a0 | ||
|
|
7998d6f878 | ||
|
|
ed6e232756 | ||
|
|
567fabbbc6 | ||
|
|
d77a956276 | ||
|
|
3c885e043d | ||
|
|
9ae013ae3c | ||
|
|
1bae64d8c4 | ||
|
|
f8792c8cf0 | ||
|
|
198bfff2de | ||
|
|
d3f0665105 | ||
|
|
77b960f14a | ||
|
|
b388aae473 | ||
|
|
81c6d70b7c | ||
|
|
f3928d8462 | ||
|
|
c22d755cf4 | ||
|
|
72cfaad618 | ||
|
|
22897150d8 | ||
|
|
395a69b4ef | ||
|
|
547439d94c | ||
|
|
84f743c4ef | ||
|
|
22a8cfe6d3 | ||
|
|
3025b7e2f7 | ||
|
|
1b2460171e | ||
|
|
f822f92321 | ||
|
|
042ba76480 | ||
|
|
3458e12274 | ||
|
|
d9364f7a4a | ||
|
|
fd0db0b188 | ||
|
|
c9c1e13743 | ||
|
|
25296d8c6f | ||
|
|
34c7981f69 | ||
|
|
f7a658e13d | ||
|
|
1d639bd0c5 | ||
|
|
5ee07390b7 | ||
|
|
83ad67bd51 | ||
|
|
72be1f1289 | ||
|
|
0285565322 | ||
|
|
acc3adb2c1 | ||
|
|
af37800c1d | ||
|
|
86eecc6606 | ||
|
|
349aab72f0 | ||
|
|
bfa65dde70 | ||
|
|
d099d8f0ac | ||
|
|
5190f52857 | ||
|
|
5790107f49 | ||
|
|
6fd21ae37e | ||
|
|
b95c321660 | ||
|
|
01bb721c33 | ||
|
|
0061f113db | ||
|
|
1fb3fbbd88 | ||
|
|
d3f8bd6cae | ||
|
|
0642e2fc9b | ||
|
|
cc017b1f0d | ||
|
|
6c2f51e35e | ||
|
|
47db984f52 | ||
|
|
0c4615e337 | ||
|
|
85e46f0163 | ||
|
|
9913fde749 | ||
|
|
1f940f61c6 | ||
|
|
70e38fe66d | ||
|
|
872ef2b97f | ||
|
|
33fb89340a | ||
|
|
bd9bf326c0 | ||
|
|
d48414b0a5 | ||
|
|
b6a7d11e5a | ||
|
|
75ce916be9 | ||
|
|
c768366240 | ||
|
|
ca7d479e90 | ||
|
|
5bfbc264b7 | ||
|
|
9f8d3db2b4 | ||
|
|
4b0d161f95 | ||
|
|
b2b8b5bf9a | ||
|
|
beda0fe9bd | ||
|
|
8fa3951bea | ||
|
|
9724e386c3 | ||
|
|
f2de7bf84c | ||
|
|
84b8188db9 | ||
|
|
19b5bcbe0f | ||
|
|
7c8f636b98 | ||
|
|
5745d97232 | ||
|
|
86f0bff332 | ||
|
|
30ab6f923d | ||
|
|
839e8fc8ac | ||
|
|
4c83743263 | ||
|
|
e1fde192f2 | ||
|
|
73389ea491 | ||
|
|
eeb6a30752 | ||
|
|
01669c7374 | ||
|
|
ac3a25bf2e | ||
|
|
0652117c79 | ||
|
|
2261005ed5 | ||
|
|
e80e0c9a89 | ||
|
|
79e9d6e564 | ||
|
|
0c6f2adf14 | ||
|
|
77ec1b08cd | ||
|
|
2be9fb292e | ||
|
|
88dba417ef | ||
|
|
b98f021d0f | ||
|
|
c026b5a3f6 | ||
|
|
3696cbf33e | ||
|
|
cbfdcbeaed | ||
|
|
130d684198 | ||
|
|
f0f3e15c08 | ||
|
|
19a1ea5211 | ||
|
|
6c2c808478 | ||
|
|
adc9a45f05 | ||
|
|
50186474d4 | ||
|
|
ffab77c35e | ||
|
|
cde2229e59 | ||
|
|
397fce1f9d | ||
|
|
f044916f94 | ||
|
|
0415564a7d | ||
|
|
ed6f2abc23 | ||
|
|
96a0477555 | ||
|
|
da5464acf6 | ||
|
|
1c8fc18fad | ||
|
|
fbf667e009 | ||
|
|
071ba358a9 | ||
|
|
ef4db2e93d | ||
|
|
6a2ef52aa0 | ||
|
|
d821275588 | ||
|
|
59966e817c | ||
|
|
b1df686a2e | ||
|
|
ae426dcc1c | ||
|
|
1646684af9 | ||
|
|
ac58c28617 | ||
|
|
7d72121bd7 | ||
|
|
10235f9d72 | ||
|
|
5d311e7557 | ||
|
|
5d86327e4d | ||
|
|
61903b534a | ||
|
|
ee61d86546 | ||
|
|
06a2cff140 | ||
|
|
2f36d0dd32 | ||
|
|
d5a2a9b2da | ||
|
|
8ee1591868 | ||
|
|
18c377e0d7 | ||
|
|
00a01c2bc4 | ||
|
|
00e8841e93 | ||
|
|
f79bb31ee6 | ||
|
|
d6449d014e | ||
|
|
b853871667 | ||
|
|
f796439cf2 | ||
|
|
692175b897 | ||
|
|
68dc20cba2 | ||
|
|
90dbae4c7a | ||
|
|
564e588f5e | ||
|
|
8f4b06542e | ||
|
|
7513512000 | ||
|
|
7b04ecdddb | ||
|
|
50338b34f9 | ||
|
|
75268bed5c | ||
|
|
e873e2aeed | ||
|
|
b27491061e | ||
|
|
9e096a4113 | ||
|
|
8c7bf7dd15 | ||
|
|
f7dd59839c | ||
|
|
84c4759f58 | ||
|
|
e345d3940c | ||
|
|
d59301ed2a | ||
|
|
48751783a7 | ||
|
|
691172d01f | ||
|
|
eb51d0365f | ||
|
|
422bf89182 | ||
|
|
4962fbcb51 | ||
|
|
be2b481385 | ||
|
|
d169ef3641 | ||
|
|
2a64972321 | ||
|
|
33fac7f765 | ||
|
|
5c2e3e1a12 | ||
|
|
4a24667e80 | ||
|
|
c3d9dc3007 | ||
|
|
df0a9401b1 | ||
|
|
f7f086faae | ||
|
|
6ae64b1723 | ||
|
|
7d41072c0e | ||
|
|
2f75b12add | ||
|
|
352dd1f2fc | ||
|
|
bdf0bc7b1e | ||
|
|
b1f490a2f8 | ||
|
|
73f617db7b | ||
|
|
1da8490dbc | ||
|
|
6e79c5c242 | ||
|
|
f4db03d31c | ||
|
|
8bc1096099 | ||
|
|
a23247d431 | ||
|
|
6a37945025 | ||
|
|
dcada8fe75 | ||
|
|
f80cecc864 | ||
|
|
1d6ee13aae | ||
|
|
01d3ed7172 | ||
|
|
a1411c885f | ||
|
|
6e48fcee76 | ||
|
|
42a0c30139 | ||
|
|
87f2fa9767 | ||
|
|
8463c6dce4 | ||
|
|
9b77ac0cab | ||
|
|
0afae74386 | ||
|
|
56c1ab0824 | ||
|
|
1ec23994f2 | ||
|
|
2950434ed3 | ||
|
|
1aca139c65 | ||
|
|
fa451306fc | ||
|
|
c179cef365 | ||
|
|
3511f8ac00 | ||
|
|
1579ec9a87 | ||
|
|
cbc6926e3d | ||
|
|
9678b422ff | ||
|
|
d1bf31729d | ||
|
|
a89a2052b8 | ||
|
|
6c80839e7b | ||
|
|
972ac3b5f0 | ||
|
|
caa8961938 | ||
|
|
619826fbc8 | ||
|
|
fe62d1bf6a | ||
|
|
95f20587ef | ||
|
|
8171ad39e0 | ||
|
|
0c9b79947d | ||
|
|
4c9680787d | ||
|
|
6eeb9e4b7d | ||
|
|
80b2240ef0 | ||
|
|
2f142724c5 | ||
|
|
174c2903d7 | ||
|
|
1f4c8e39f8 | ||
|
|
3caab6d2ea | ||
|
|
4e5a9bd600 | ||
|
|
fef34d360b | ||
|
|
05ddd9c204 | ||
|
|
ba2e44c6a4 | ||
|
|
4f07ed42e3 | ||
|
|
66716023e4 | ||
|
|
4bc2ff997a | ||
|
|
b1633f2454 | ||
|
|
41a91188f5 | ||
|
|
4def600076 | ||
|
|
18a18e4c72 | ||
|
|
85c90671bc | ||
|
|
16b688eced | ||
|
|
37c55eb192 | ||
|
|
2d7dc3e82d | ||
|
|
e7a8a7247c | ||
|
|
c4818a9fb2 | ||
|
|
8c2a7146df | ||
|
|
311e3206c9 | ||
|
|
6ad6b3d2a6 | ||
|
|
471a05fd59 | ||
|
|
7a12655111 | ||
|
|
1b26869b74 | ||
|
|
13f35d80a9 | ||
|
|
1c4faa7d8a | ||
|
|
c26ed53927 | ||
|
|
fe0f6e96b3 | ||
|
|
6dd7ccee68 | ||
|
|
9327cf8af5 | ||
|
|
512b52e23a | ||
|
|
5df7105301 | ||
|
|
a84fdb771f | ||
|
|
ff75341c75 | ||
|
|
f0d48a96ca | ||
|
|
215fdf119e | ||
|
|
985b646ee1 | ||
|
|
622e480c4b | ||
|
|
2e78a46c52 | ||
|
|
b1b6e53d6f | ||
|
|
65325f7f81 | ||
|
|
9bd82e5a24 | ||
|
|
0689b4558e | ||
|
|
dbea934701 | ||
|
|
8e4d5fb38f | ||
|
|
e324ee9823 | ||
|
|
54e9cabf5d | ||
|
|
7a3f6fb53d | ||
|
|
59a9576498 | ||
|
|
57eb3886ba | ||
|
|
fe9e6db0e2 | ||
|
|
db8eeb6c6e | ||
|
|
2b7328535d | ||
|
|
d4e5424360 | ||
|
|
d67d992749 | ||
|
|
b6c7aafe55 | ||
|
|
9829384829 | ||
|
|
1d79c1982a | ||
|
|
f6259531c3 | ||
|
|
ed03039d19 | ||
|
|
b6abc4623b | ||
|
|
d1949b7b42 | ||
|
|
b6e30427a3 | ||
|
|
96e0dcf5d5 | ||
|
|
ab48435211 | ||
|
|
8bcb05d6c0 | ||
|
|
6b363d6af9 | ||
|
|
2fd2a8662d | ||
|
|
f1db0809b1 | ||
|
|
30ca072f50 | ||
|
|
85ea53198a | ||
|
|
7ec4c1424d | ||
|
|
f95513e86b | ||
|
|
8baacecdcf | ||
|
|
ff6e30cec4 | ||
|
|
308275c8a8 | ||
|
|
5ed6534aa3 | ||
|
|
120ca0e3a5 | ||
|
|
d193802613 | ||
|
|
50b4d2eb6b | ||
|
|
36db032ca0 | ||
|
|
afbcc31c6a | ||
|
|
52c35b18da | ||
|
|
454a5ad1ec | ||
|
|
1698f0f57c | ||
|
|
bb6d7334d0 | ||
|
|
659ec4d6ea | ||
|
|
2e50204700 | ||
|
|
39dc9a7ba6 | ||
|
|
65ef2592f6 | ||
|
|
ad0aed3ba5 | ||
|
|
0d868b9ec1 | ||
|
|
5f440dfe13 | ||
|
|
768f8832b9 | ||
|
|
32f20dddd6 | ||
|
|
7aa93a3ecb | ||
|
|
b07dd76453 | ||
|
|
4600b4ab22 | ||
|
|
a8d2dce563 | ||
|
|
5e845ee265 | ||
|
|
a9b7a4a1de | ||
|
|
32d2f78239 | ||
|
|
2a3a8b8008 | ||
|
|
90a63d4d89 | ||
|
|
66f74ed579 | ||
|
|
d376d11d42 | ||
|
|
6664acd27f | ||
|
|
525bcd4e2d | ||
|
|
34a64070ca | ||
|
|
67f2074c81 | ||
|
|
e6717e3d68 | ||
|
|
271eac7381 | ||
|
|
4bf4036bf7 | ||
|
|
22c210c8b9 | ||
|
|
afc3888391 | ||
|
|
411b565cca | ||
|
|
f6c06ac786 | ||
|
|
852a6ff175 | ||
|
|
d6f4d936ee | ||
|
|
cba1820168 | ||
|
|
0cfc88d2ee | ||
|
|
ec3eed5d2a | ||
|
|
49873f4fea | ||
|
|
ee29bf8d42 | ||
|
|
0e0bfe6686 | ||
|
|
fafea15fa8 | ||
|
|
3752981cfa | ||
|
|
9ec1003f1e | ||
|
|
64c99bcfd4 | ||
|
|
d4351183d9 | ||
|
|
cef5c93bca | ||
|
|
eb4e23274d | ||
|
|
dacdc72581 | ||
|
|
6846014def | ||
|
|
07ef99a8f0 | ||
|
|
857af600f7 | ||
|
|
3cbced4e4e | ||
|
|
85e4a0e6ec | ||
|
|
45aca40f6c | ||
|
|
7ecbba089f | ||
|
|
205ddfb7c9 | ||
|
|
8a50b207eb | ||
|
|
9f99ccdca3 | ||
|
|
f49b605514 | ||
|
|
52b4bab461 | ||
|
|
f1ccaf86a4 | ||
|
|
b59ce51760 | ||
|
|
60d2c6fddb | ||
|
|
25a563119b | ||
|
|
a4c9d5826d | ||
|
|
1d3b89458e | ||
|
|
f94b71038e | ||
|
|
076f4b4db1 | ||
|
|
18829a56e4 | ||
|
|
ac7b1b3c1f | ||
|
|
b74f71fbed | ||
|
|
c3c0f4bd89 | ||
|
|
e860ade718 | ||
|
|
e9a8c6cb62 | ||
|
|
473a68dbf9 | ||
|
|
885d8836d1 | ||
|
|
e92ae37dc3 | ||
|
|
e6af9763fd | ||
|
|
ca73dae1f0 | ||
|
|
3623215b8c | ||
|
|
a1376ac8ea | ||
|
|
9d724cb72a | ||
|
|
91ba14e77e | ||
|
|
2cab75d72b | ||
|
|
b37a74533d | ||
|
|
939d0f25c5 | ||
|
|
61929d2e2f | ||
|
|
a7658f9d75 | ||
|
|
033e91b7b9 | ||
|
|
68de34c03e | ||
|
|
94c05e346d | ||
|
|
45298c0a37 | ||
|
|
c12fc1afea | ||
|
|
136b5b0be9 | ||
|
|
9203651110 | ||
|
|
a394ceaef1 | ||
|
|
0ab28ef8ee | ||
|
|
b928b8b3a2 | ||
|
|
075fc96f10 | ||
|
|
15f6255c7c | ||
|
|
2b79519ad1 | ||
|
|
617a8876a6 | ||
|
|
7b7af57813 | ||
|
|
a12f6ec70c | ||
|
|
fffc3b1e0e | ||
|
|
af12ec2b01 | ||
|
|
ecfc7d752a | ||
|
|
bc096994b0 | ||
|
|
ba80074b7b | ||
|
|
f04d883ac1 | ||
|
|
9bf718dd82 | ||
|
|
643d5600b2 | ||
|
|
1edae9c6c1 | ||
|
|
b41e5f5bf6 | ||
|
|
2f6ecc1328 | ||
|
|
b93288875f | ||
|
|
bb4f699d03 | ||
|
|
f1d991fa8b | ||
|
|
4ce7854f44 | ||
|
|
5ef35ee1bd | ||
|
|
6d5bccc050 | ||
|
|
3ac2c1dd18 | ||
|
|
07a41ecf6f | ||
|
|
61e85a578e | ||
|
|
88d68587e1 | ||
|
|
23ae04e6cb | ||
|
|
64c05f2ce9 | ||
|
|
c5cb60a752 | ||
|
|
803e4f5524 | ||
|
|
a909bfaf85 | ||
|
|
bc11e9f300 | ||
|
|
e3412d4207 | ||
|
|
faf8b01ecc | ||
|
|
d7337c5b26 | ||
|
|
2ab1086b80 | ||
|
|
85f2f88c59 | ||
|
|
ce3422e75a | ||
|
|
bee87843b4 | ||
|
|
18aef6ac33 | ||
|
|
890f6031c3 | ||
|
|
f3bace570d | ||
|
|
533511f8c3 | ||
|
|
6489354b0e | ||
|
|
1bbae013cc | ||
|
|
8ac8129fe7 | ||
|
|
9667a38bc9 | ||
|
|
e3df7f033e | ||
|
|
989fd92b84 | ||
|
|
de24170a79 | ||
|
|
5a0548621f | ||
|
|
0f8e472dab | ||
|
|
b190fa38c7 | ||
|
|
b0b01dae81 | ||
|
|
f2b4ba6110 | ||
|
|
d15d0ba6a5 | ||
|
|
fc3af50b55 | ||
|
|
a0a141b457 | ||
|
|
0315ca2701 | ||
|
|
9f4f973277 | ||
|
|
b825e16e36 | ||
|
|
24b4db4352 | ||
|
|
06941ac7a2 | ||
|
|
91d0360a11 | ||
|
|
17bae5bba2 | ||
|
|
1a41fff009 | ||
|
|
7739c495e7 | ||
|
|
5607f7a2c8 | ||
|
|
2a74416d68 | ||
|
|
65f08ea175 | ||
|
|
70b9bdcc9a | ||
|
|
584d5d1a81 | ||
|
|
9e7ab38bce | ||
|
|
71f5a01b83 | ||
|
|
df8ac1cfe6 | ||
|
|
72b6a0a0c9 | ||
|
|
93cf836564 | ||
|
|
d2223ee5e3 | ||
|
|
b6ab8d6776 | ||
|
|
456989ca8d | ||
|
|
2e27d1f763 | ||
|
|
27a83f3dd3 | ||
|
|
79aadb4bc9 | ||
|
|
43d0715238 | ||
|
|
fb8e093389 | ||
|
|
4b47c3ab73 | ||
|
|
a0eff85d73 | ||
|
|
aa36719bd9 | ||
|
|
33aa71c38f | ||
|
|
1f20d7da25 | ||
|
|
dfcf825721 | ||
|
|
eaae041b4c | ||
|
|
dbd79746b1 | ||
|
|
f1a27b8f33 | ||
|
|
86c8e5455a | ||
|
|
dc37b82298 | ||
|
|
7d09b84ded | ||
|
|
53894e1e2b | ||
|
|
7e3ccbe835 | ||
|
|
8b8b6a866d | ||
|
|
222e606f89 | ||
|
|
83c47552e8 | ||
|
|
03851cab90 | ||
|
|
bb6d89bbc3 | ||
|
|
b061f985cf | ||
|
|
ecd7c17ffd | ||
|
|
a71a352822 | ||
|
|
c08c921b3f | ||
|
|
95399f1286 | ||
|
|
b5fd15c2e1 | ||
|
|
85e9dab370 | ||
|
|
8c9cf7d671 | ||
|
|
82da877863 | ||
|
|
275c480f89 | ||
|
|
477d9fbcba | ||
|
|
b88524027c | ||
|
|
55be93d5c4 | ||
|
|
c78c196423 | ||
|
|
d8656427fd | ||
|
|
41b1e87105 | ||
|
|
37678ac5ec | ||
|
|
7832d90077 | ||
|
|
3bd78cabd8 | ||
|
|
fff75b1904 | ||
|
|
97c0339f66 | ||
|
|
5b3f14df3b | ||
|
|
07cdba349d | ||
|
|
197e837e5b | ||
|
|
13bd4ce46a | ||
|
|
a43d1af23e | ||
|
|
cbf483143f | ||
|
|
cf5fbb9d65 | ||
|
|
d699b80254 | ||
|
|
ead414d0a7 | ||
|
|
cfdabf874a | ||
|
|
e954254abb | ||
|
|
93d4bb8361 | ||
|
|
edb0aac091 | ||
|
|
9549a32500 | ||
|
|
a949f9eca2 | ||
|
|
f4bbad6323 | ||
|
|
8a4d4864ea | ||
|
|
a8de38d0b0 | ||
|
|
18dc82c6b6 | ||
|
|
897c1c684e | ||
|
|
1ebcb09fc1 | ||
|
|
0f11226ced | ||
|
|
dada404a6b | ||
|
|
e4a37d6a5e | ||
|
|
66b93e8fd2 | ||
|
|
d9df632671 | ||
|
|
aa2d15aa33 | ||
|
|
0b55ebb150 | ||
|
|
7c11564613 | ||
|
|
c3f864f2b6 | ||
|
|
a29a30effc | ||
|
|
0af2722926 | ||
|
|
78efec09d5 | ||
|
|
1fdeadd113 | ||
|
|
a1464dbad7 | ||
|
|
dd2a66d00c | ||
|
|
1152fda687 | ||
|
|
fd0e929087 | ||
|
|
8b3e0e52f1 | ||
|
|
8ff080fb99 | ||
|
|
6bca228888 | ||
|
|
fd1e588645 | ||
|
|
024d9e6df7 | ||
|
|
aca8d3f34c | ||
|
|
e2030a740d | ||
|
|
27b745d04f | ||
|
|
f712d07b23 | ||
|
|
f8ea5e0942 | ||
|
|
89db0dd44d | ||
|
|
94e5a589b6 | ||
|
|
2dbb23f973 | ||
|
|
b71028dc73 | ||
|
|
f5aab14766 | ||
|
|
273c5e99c1 | ||
|
|
7ba37b5dc0 | ||
|
|
059d3856cf | ||
|
|
9dbd265fdd | ||
|
|
09ae63f822 | ||
|
|
c9becd3ea1 | ||
|
|
5a245b3d55 | ||
|
|
7d3b16fe73 | ||
|
|
fd85b25d29 | ||
|
|
5eebf74f69 | ||
|
|
5a11c6597c | ||
|
|
930b324c15 | ||
|
|
d952dea32b | ||
|
|
9a6ac7ab69 | ||
|
|
df43ee640d | ||
|
|
309b57f4ea | ||
|
|
cc839caba5 | ||
|
|
d734648b15 | ||
|
|
006400905b | ||
|
|
1e1e964d25 | ||
|
|
263e0b7692 | ||
|
|
01d4d0131b | ||
|
|
f41e4befde | ||
|
|
94fca31be8 | ||
|
|
19db459fca | ||
|
|
7693173ecd | ||
|
|
a0294cbae8 | ||
|
|
1cf008cbe3 | ||
|
|
87b84ffded | ||
|
|
035e56215d | ||
|
|
fa4d420fdb | ||
|
|
bd27bf7677 | ||
|
|
03d9ebb56e | ||
|
|
113b48a2ad | ||
|
|
6aed8f1c87 | ||
|
|
6d681c5b8a | ||
|
|
b3034292f2 | ||
|
|
4243791b47 | ||
|
|
b79c69140d | ||
|
|
ede004169c | ||
|
|
37dad2172b | ||
|
|
c8c471a128 | ||
|
|
f72ff72c0c | ||
|
|
dc3bfac876 | ||
|
|
426223dda0 | ||
|
|
5909d6a0c5 | ||
|
|
5570929b56 | ||
|
|
5ba6670164 | ||
|
|
589442b09b | ||
|
|
0c67cff2a0 | ||
|
|
9c3d5705b5 | ||
|
|
2f2662e7a5 | ||
|
|
99040535d7 | ||
|
|
582f00ed95 | ||
|
|
1d2f906af1 | ||
|
|
dfb8ff372d | ||
|
|
1e37e42239 | ||
|
|
ce1bd142e2 | ||
|
|
35015e5ceb | ||
|
|
03b56ffd1f | ||
|
|
065963f6d3 | ||
|
|
a71319a080 | ||
|
|
9ea7249368 | ||
|
|
301e24c06c | ||
|
|
6b108404ba | ||
|
|
0b661b6d7f | ||
|
|
3ab68a6896 | ||
|
|
97d8e39932 | ||
|
|
5c71c1cf19 | ||
|
|
dc8aa9ef83 | ||
|
|
ab54e1f66a | ||
|
|
0fd5493220 | ||
|
|
5c3f75d90a | ||
|
|
e8aabd4652 | ||
|
|
350bd188df | ||
|
|
7e9ba53d82 | ||
|
|
16208f7ad7 | ||
|
|
cc822e08aa | ||
|
|
c3880e52e4 | ||
|
|
a5aa03b983 | ||
|
|
06b7baabcc | ||
|
|
b7cffeed8c | ||
|
|
380df0121b | ||
|
|
611e0335cc | ||
|
|
22136a708b | ||
|
|
2a29e87eb9 | ||
|
|
ea9e8c0c9b | ||
|
|
58d61c290a | ||
|
|
bad6049d73 | ||
|
|
24b26026ef | ||
|
|
4629beecd7 | ||
|
|
f67793cb0d | ||
|
|
538c16cd00 | ||
|
|
3a26eea0cc | ||
|
|
f9ef2cd32e | ||
|
|
493ddbd99e | ||
|
|
f00d9c5eff | ||
|
|
95be78ac5e | ||
|
|
e9c263c326 | ||
|
|
1bace6df4e | ||
|
|
0439c35198 | ||
|
|
a816e538ab | ||
|
|
bbd117bd92 | ||
|
|
d448e7d841 | ||
|
|
6fcfba229d | ||
|
|
d525636423 | ||
|
|
d11402612f | ||
|
|
6079a025ca | ||
|
|
81f0c203a9 | ||
|
|
60822641cb | ||
|
|
fac02b58bc | ||
|
|
c9902f34d1 | ||
|
|
8b45c0a856 | ||
|
|
2a5ad4664b | ||
|
|
b98720d324 | ||
|
|
3f0b5fbd71 | ||
|
|
fa1034b04c | ||
|
|
13ed2183ee | ||
|
|
6fae1f60fd | ||
|
|
a46144e022 | ||
|
|
7f754caba3 | ||
|
|
2372823fd8 | ||
|
|
52282a5a26 | ||
|
|
96f55a7ac7 | ||
|
|
990dcc8eef | ||
|
|
76bff0d4de | ||
|
|
59f2767345 | ||
|
|
bba6562dcc | ||
|
|
f3aa5e40fb | ||
|
|
1e2dab3c0c | ||
|
|
bc8fc2d4e4 | ||
|
|
15b76e93d1 | ||
|
|
bc2a311a38 | ||
|
|
f19955705f | ||
|
|
e4902af15a | ||
|
|
ab9d856568 | ||
|
|
dd1d128333 | ||
|
|
a629654a15 | ||
|
|
08a8d7bf51 | ||
|
|
335d36088f | ||
|
|
0b9a95e294 | ||
|
|
98acc84111 | ||
|
|
261c01dfa3 | ||
|
|
dbda19f658 | ||
|
|
8067022d98 | ||
|
|
72ba56b071 | ||
|
|
30046f35d7 | ||
|
|
10451e9e38 | ||
|
|
ea7f15917f | ||
|
|
df3e711ee0 | ||
|
|
263e903046 | ||
|
|
f7bbac0ab9 | ||
|
|
9ebcb691b0 | ||
|
|
601e1d3dc9 | ||
|
|
7b0a8f9bdc | ||
|
|
dd36324756 | ||
|
|
1b5d0af824 | ||
|
|
edcca8cd3f | ||
|
|
c95ca15b49 | ||
|
|
055117e07a | ||
|
|
ebbabaea5b | ||
|
|
eba53f8f94 | ||
|
|
071f54ac59 | ||
|
|
8796c1c601 | ||
|
|
8c0f74f036 | ||
|
|
5a820262f9 | ||
|
|
3906456993 | ||
|
|
a1407565c8 | ||
|
|
a7c5a2e65d | ||
|
|
10ac4dbc35 | ||
|
|
6469cbc62a | ||
|
|
1961de6b5d | ||
|
|
ef4eb47d50 | ||
|
|
295088f9e8 | ||
|
|
4222afe3c7 | ||
|
|
79d89a3c20 | ||
|
|
8ad414b217 | ||
|
|
7b1418be3b | ||
|
|
7396c6911d | ||
|
|
673c707085 | ||
|
|
f21d05a235 | ||
|
|
1dd19c1a72 | ||
|
|
a8d9695324 | ||
|
|
99d539b9a7 | ||
|
|
179cb2c88a | ||
|
|
9629da863d | ||
|
|
4f76e6f577 | ||
|
|
0f3cef4091 | ||
|
|
7665cbf21d | ||
|
|
b9413ab316 | ||
|
|
a3bff7d6a2 | ||
|
|
7e54dc7903 | ||
|
|
fb1220af97 | ||
|
|
282c7e85ec | ||
|
|
bc15bb53dc | ||
|
|
a729e059de | ||
|
|
7c628f7689 | ||
|
|
6d65c28f1f | ||
|
|
31e4ef5e4b | ||
|
|
d38341b5e0 | ||
|
|
ff90d9da9c | ||
|
|
84c62ed034 | ||
|
|
e76ba05516 | ||
|
|
90d99b16f1 | ||
|
|
3cedba1de8 | ||
|
|
ccbf26be0a | ||
|
|
6448490de5 | ||
|
|
98651dae9d | ||
|
|
bf57ef400d | ||
|
|
27cae04446 | ||
|
|
430eadc1b2 | ||
|
|
e954737a92 | ||
|
|
191d5222e7 | ||
|
|
e77af4b40f | ||
|
|
da3c47259d | ||
|
|
c95575b284 | ||
|
|
7a5086a2be | ||
|
|
c3a665320e | ||
|
|
372dfecf05 | ||
|
|
68bd6809a7 | ||
|
|
7bfdd07a71 | ||
|
|
6bc93173f1 | ||
|
|
55af9f8a40 | ||
|
|
866b35d27c | ||
|
|
5374119f18 | ||
|
|
919404df53 | ||
|
|
fd07c74578 | ||
|
|
560961e3fc | ||
|
|
873e49ab66 | ||
|
|
0f8f786f9f | ||
|
|
7b3e267729 | ||
|
|
7264bb55b2 | ||
|
|
ed6dfed67f | ||
|
|
3488066031 | ||
|
|
bc9ea93f50 | ||
|
|
1920b79a0d | ||
|
|
9131570703 | ||
|
|
770c1a973f | ||
|
|
b7b21a0b72 | ||
|
|
4d91fb4910 | ||
|
|
4ce9d6f29a | ||
|
|
d2a4c503f7 | ||
|
|
a2700bc17f | ||
|
|
0a04d73883 | ||
|
|
502dae3c1f | ||
|
|
e9c766277d | ||
|
|
762f3907fa | ||
|
|
3698b64a10 | ||
|
|
2a6c160d39 | ||
|
|
795754cd60 | ||
|
|
517343ddb5 | ||
|
|
90a5e2f9af | ||
|
|
93180fbb6d | ||
|
|
04cb78947a | ||
|
|
5423f2d5cb | ||
|
|
51d15b7293 | ||
|
|
7a2e018df8 | ||
|
|
1fd4beb18a | ||
|
|
33d7644b4f | ||
|
|
5a98e4f4e8 | ||
|
|
82ae53dd75 | ||
|
|
07db04e773 | ||
|
|
6a8ee475fd | ||
|
|
767a7a7c21 | ||
|
|
a3b56f7eb1 | ||
|
|
5e1a998cde | ||
|
|
219fbc0056 | ||
|
|
dcee6413f4 | ||
|
|
e2895239d8 | ||
|
|
c8077c8d9f | ||
|
|
46c2d5a8f2 | ||
|
|
adb127bb3e | ||
|
|
42f0285278 | ||
|
|
13ef23f517 | ||
|
|
0bf28b19ab | ||
|
|
29a0af78bc | ||
|
|
cf487c771e | ||
|
|
7e711089a8 | ||
|
|
1c81a40a76 | ||
|
|
2b64c6d951 | ||
|
|
dba8f91f99 | ||
|
|
8e70e71143 | ||
|
|
f43a7c4f24 | ||
|
|
4e56d92ed8 | ||
|
|
5645d733ba | ||
|
|
42b07f1f47 | ||
|
|
e75354b3b0 | ||
|
|
80122856c4 | ||
|
|
308238ab42 | ||
|
|
e937cf78cf | ||
|
|
2ae2fdc9f8 | ||
|
|
3184834d72 | ||
|
|
8ef5534d92 | ||
|
|
41bb96be5d | ||
|
|
b37055fa47 | ||
|
|
515b727f52 | ||
|
|
77d6d1e8c2 | ||
|
|
04b614ce10 | ||
|
|
62e11ddbe4 | ||
|
|
8e3ab5921f | ||
|
|
1d87997647 | ||
|
|
b58e0ef991 | ||
|
|
db959da247 | ||
|
|
6199252011 | ||
|
|
40c0a7b50b | ||
|
|
422bc4aaa6 | ||
|
|
225c89fbf1 | ||
|
|
76281ff15c | ||
|
|
8b54ff699f | ||
|
|
7d160650b8 | ||
|
|
803e46cda7 | ||
|
|
004fe2ad12 | ||
|
|
09baf2091e | ||
|
|
135a94b4f7 | ||
|
|
a41d185768 | ||
|
|
c3432e57b1 | ||
|
|
a8d88d193e | ||
|
|
471e4d6e72 | ||
|
|
14fec4cfb3 | ||
|
|
4bcd1c6fcd | ||
|
|
84e1a89c44 | ||
|
|
e0162df465 | ||
|
|
7631456047 | ||
|
|
2bc51ab2bd | ||
|
|
d23ecef831 | ||
|
|
c0017ce76d | ||
|
|
30f9da9d71 | ||
|
|
e242ca0937 | ||
|
|
17596b0dc6 | ||
|
|
8e87a2d80d | ||
|
|
4964f53a42 | ||
|
|
6250fa8529 | ||
|
|
944e1c0378 | ||
|
|
4f446241a4 | ||
|
|
97659a1193 | ||
|
|
0bcf71f8df | ||
|
|
ab3bb9cf4d | ||
|
|
69126a31db | ||
|
|
03e3803cff | ||
|
|
58f8c7c613 | ||
|
|
acd1c76c3b | ||
|
|
4c8cc5e3f3 | ||
|
|
72bb33f962 | ||
|
|
2e61e52520 | ||
|
|
75490d0375 | ||
|
|
0fbe4cb6b9 | ||
|
|
d2b3f49384 | ||
|
|
136992b8df | ||
|
|
a130f848f2 | ||
|
|
e10bc9e3c0 | ||
|
|
d56741ca4f | ||
|
|
92c9ed2d6c | ||
|
|
50a5ad54ce | ||
|
|
9dcb44ba61 | ||
|
|
8bdc4b544f | ||
|
|
e763f843c4 | ||
|
|
b5732e31c6 | ||
|
|
ea24ffdd51 | ||
|
|
56f7fbf2d1 | ||
|
|
89b53ea39c | ||
|
|
9cc69277bc | ||
|
|
7e79ed6d4e | ||
|
|
b5190d8df2 | ||
|
|
b03c93c4fe | ||
|
|
8e12ddf7ed | ||
|
|
4fd866d113 | ||
|
|
a59410a254 | ||
|
|
b1a27ad633 | ||
|
|
4a3ad7f348 | ||
|
|
89e4ab8a45 | ||
|
|
fd8e34650e | ||
|
|
e26c8ce499 | ||
|
|
64cf8a4534 | ||
|
|
ae976f60ca | ||
|
|
f152860bc5 | ||
|
|
40153b7422 | ||
|
|
fdfe6a8340 | ||
|
|
79c100008a | ||
|
|
f132c7891b | ||
|
|
bdad984ace | ||
|
|
a229627a54 | ||
|
|
0b598cf132 | ||
|
|
0e657eece1 | ||
|
|
b6cf1df659 | ||
|
|
29afe2d21c | ||
|
|
a722c6236c | ||
|
|
14aedc416a | ||
|
|
9fe0cb4954 | ||
|
|
2a5669967f | ||
|
|
13376d22de | ||
|
|
6b21531916 | ||
|
|
4a4dcb30ef | ||
|
|
2cfa58b433 | ||
|
|
c6dd846718 | ||
|
|
7a2d76d002 | ||
|
|
e5a8febe3b | ||
|
|
60809719b8 | ||
|
|
ee6a8ab93a | ||
|
|
c3d92095f8 | ||
|
|
460beae671 | ||
|
|
fa6c8ab321 | ||
|
|
d02f86bef5 | ||
|
|
0d74c1b4f0 | ||
|
|
8f3539c14f | ||
|
|
3d5e692c2c | ||
|
|
cb622e99d8 | ||
|
|
567d59e48a | ||
|
|
f89f71262d | ||
|
|
5e2ee5eb6a | ||
|
|
34a54dac2d | ||
|
|
e329930a82 | ||
|
|
3940846d79 | ||
|
|
c608fbe89e | ||
|
|
8db00eedea | ||
|
|
0e904dda79 | ||
|
|
e4af6adaf7 | ||
|
|
e1c7c49a0c | ||
|
|
bd9f148d24 | ||
|
|
f009011179 | ||
|
|
5adb854aa5 | ||
|
|
1f51524bae | ||
|
|
23f8dbed80 | ||
|
|
140acfe4cc | ||
|
|
cb2cb2cff7 | ||
|
|
30300fc6b9 | ||
|
|
de8982563a | ||
|
|
e7154b3af9 | ||
|
|
39360dc419 | ||
|
|
eeb61929ac | ||
|
|
56fd7031e5 | ||
|
|
425fe7f22d | ||
|
|
ed51fc7636 | ||
|
|
d23a7ca8d5 | ||
|
|
1b1dc2a429 | ||
|
|
be2aeee70f | ||
|
|
8a3deb98cd | ||
|
|
e4902143f8 | ||
|
|
d3a374777b | ||
|
|
5b94d9b803 | ||
|
|
b6652abc7c | ||
|
|
97f0bacfa0 | ||
|
|
210bc6aa66 | ||
|
|
8170d5e340 | ||
|
|
6225902034 | ||
|
|
0487e9eafe | ||
|
|
73669e09c8 | ||
|
|
da510508bb | ||
|
|
02ae0c22ef | ||
|
|
edee511cd1 | ||
|
|
fbd35ec332 | ||
|
|
30b35e3727 | ||
|
|
330cafd3d2 | ||
|
|
fe9024218c | ||
|
|
0c9bd3259e | ||
|
|
b23e2e807a | ||
|
|
7876acf960 | ||
|
|
74166e224b | ||
|
|
cb778d033f | ||
|
|
1bf7da148a | ||
|
|
d58a72ee32 | ||
|
|
15d195d2f0 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,5 +1,5 @@
|
||||
**/*/log/*
|
||||
**/*/tmp/*
|
||||
test/rails_app/log/*
|
||||
test/rails_app/tmp/*
|
||||
*~
|
||||
coverage/*
|
||||
*.sqlite3
|
||||
@@ -7,4 +7,4 @@ coverage/*
|
||||
rdoc/*
|
||||
pkg
|
||||
log
|
||||
test/tmp/*
|
||||
test/tmp/*
|
||||
|
||||
46
.travis.yml
46
.travis.yml
@@ -1 +1,45 @@
|
||||
script: "rake test"
|
||||
language: ruby
|
||||
|
||||
rvm:
|
||||
- 1.9.3
|
||||
- 2.0.0
|
||||
- 2.1
|
||||
- 2.2
|
||||
|
||||
gemfile:
|
||||
- gemfiles/Gemfile.rails-4.2-stable
|
||||
- gemfiles/Gemfile.rails-4.1-stable
|
||||
- gemfiles/Gemfile.rails-4.0-stable
|
||||
- gemfiles/Gemfile.rails-3.2-stable
|
||||
- Gemfile
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- rvm: 2.2
|
||||
gemfile: gemfiles/Gemfile.rails-3.2-stable
|
||||
|
||||
services:
|
||||
- mongodb
|
||||
|
||||
sudo: false
|
||||
|
||||
cache: bundler
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- DEVISE_ORM=mongoid
|
||||
- DEVISE_ORM=active_record
|
||||
|
||||
before_install: "rm ${BUNDLE_GEMFILE}.lock"
|
||||
|
||||
before_script: "bundle update"
|
||||
|
||||
script: "bundle exec rake test"
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
campfire:
|
||||
on_success: change
|
||||
on_failure: always
|
||||
rooms:
|
||||
- secure: "TRiqvuM4i/QmRDWjUSNitE5/P91BOzDkNl53+bZjjtxcISCswZtmECWBR7n9\n3xwqCOU1o2lfohxZ32OHOj/Nj7o+90zWJfWxcv+if0hIXRiil62M5pg0lZUd\nyJ4M5VQ0lSWo5he1OUrXhSabPJeaK3B8yT/tdh+qO5yzR+vb/jc="
|
||||
|
||||
9
.yardopts
Normal file
9
.yardopts
Normal file
@@ -0,0 +1,9 @@
|
||||
--protected
|
||||
--no-private
|
||||
--embed-mixin ClassMethods
|
||||
-
|
||||
README.md
|
||||
CHANGELOG.rdoc
|
||||
CONTRIBUTING.md
|
||||
MIT-LICENSE
|
||||
|
||||
1130
CHANGELOG.md
Normal file
1130
CHANGELOG.md
Normal file
File diff suppressed because it is too large
Load Diff
564
CHANGELOG.rdoc
564
CHANGELOG.rdoc
@@ -1,564 +0,0 @@
|
||||
== 1.2.rc2
|
||||
|
||||
* enhancements
|
||||
* Make friendly_token 20 chars long
|
||||
* Use secure_compare
|
||||
|
||||
* bug fix
|
||||
* Fix an issue causing infinite redirects in production
|
||||
* rails g destroy works properly with devise generators (by github.com/andmej)
|
||||
* before_failure callbacks should work on test helpers (by github.com/twinge)
|
||||
* rememberable cookie now is httponly by default (by github.com/JamesFerguson)
|
||||
* Add missing confirmation_keys (by github.com/JohnPlummer)
|
||||
* Ensure after_* hooks are called on RegistrationsController
|
||||
* When using database_authenticatable Devise will now only create an email field when appropriate (if using default authentication_keys or custom authentication_keys with email included)
|
||||
* Ensure stateless token does not trigger timeout (by github.com/pixelauthority)
|
||||
* Implement handle_unverified_request for Rails 3.0.4 compatibility and improve FailureApp reliance on symbols
|
||||
* Consider namespaces while generating routes
|
||||
* Custom failure apps no longer ignored in test mode (by github.com/jaghion)
|
||||
* Do not depend on ActiveModel::Dirty
|
||||
* Manual sign_in now triggers remember token
|
||||
* Be sure to halt strategies on failures
|
||||
* Consider SCRIPT_NAME on Omniauth paths
|
||||
* Reset failed attempts when lock is expired
|
||||
* Ensure there is no Mongoid injection
|
||||
|
||||
* deprecations
|
||||
* Deprecated anybody_signed_in? in favor of signed_in? (by github.com/gavinhughes)
|
||||
* Removed --haml and --slim view templates
|
||||
* Devise::OmniAuth helpers were deprecated and removed in favor of Omniauth.config.test_mode
|
||||
|
||||
== 1.2.rc
|
||||
|
||||
* deprecations
|
||||
* cookie_domain is deprecated in favor of cookie_options
|
||||
* after_update_path_for can no longer be defined in ApplicationController
|
||||
|
||||
* enhancements
|
||||
* Added OmniAuth support
|
||||
* Added ORM adapter to abstract ORM iteraction
|
||||
* sign_out_via is available in the router to configure the method used for sign out (by github.com/martinrehfeld)
|
||||
* Improved Ajax requests handling in failure app (by github.com/spastorino)
|
||||
* Added request_keys to easily use request specific values (like subdomain) in authentication
|
||||
* Increased the size of friendly_token to 60 characters (reduces the chances of a successful brute attack)
|
||||
* Ensure the friendly token does not include "_" or "-" since some e-mails may not autolink it properly (by github.com/rymai)
|
||||
* Extracted encryptors into :encryptable for better bcrypt support
|
||||
* :rememberable is now able to use salt as token if no remember_token is provided
|
||||
* Store the salt in session and expire the session if the user changes his password
|
||||
* Allow :stateless_token to be set to true avoiding users to be stored in session through token authentication
|
||||
* cookie_options uses session_options values by default
|
||||
* Sign up now check if the user is active or not and redirect him accordingly setting the inactive_signed_up message
|
||||
* Use ActiveModel#to_key instead of #id
|
||||
* sign_out_all_scopes now destroys the whole session
|
||||
* Added case_insensitive_keys that automatically downcases the given keys, by default downcases only e-mail (by github.com/adahl)
|
||||
|
||||
* default behavior changes
|
||||
* sign_out_all_scopes defaults to true as security measure
|
||||
* http authenticatable is disabled by default
|
||||
* Devise does not intercept 401 returned from applications
|
||||
|
||||
* bugfix
|
||||
* after_sign_in_path_for always receives a resource
|
||||
* Do not execute Warden::Callbacks on Devise::TestHelpers (by github.com/sgronblo)
|
||||
* Allow password recovery and account unlocking to change used keys (by github.com/RStankov)
|
||||
* FailureApp now properly handles nil request.format
|
||||
* Fix a bug causing FailureApp to return with HTTP Auth Headers for IE7
|
||||
* Ensure namespaces has proper scoped views
|
||||
* Ensure Devise does not set empty flash messages (by github.com/sxross)
|
||||
|
||||
== 1.1.6
|
||||
|
||||
* Use a more secure e-mail regexp
|
||||
* Implement Rails 3.0.4 handle unverified request
|
||||
* Use secure_compare to compare passwords
|
||||
|
||||
== 1.1.5
|
||||
|
||||
* bugfix
|
||||
* Ensure to convert keys on indifferent hash
|
||||
|
||||
* defaults
|
||||
* Set config.http_authenticatable to false to avoid confusion
|
||||
|
||||
== 1.1.4
|
||||
|
||||
* bugfix
|
||||
* Avoid session fixation attacks
|
||||
|
||||
== 1.1.3
|
||||
|
||||
* bugfix
|
||||
* Add reply-to to e-mail headers by default
|
||||
* Updated the views generator to respect the rails :template_engine option (by github.com/fredwu)
|
||||
* Check the type of HTTP Authentication before using Basic headers
|
||||
* Avoid invalid_salt errors by checking salt presence (by github.com/thibaudgg)
|
||||
* Forget user deletes the right cookie before logout, not remembering the user anymore (by github.com/emtrane)
|
||||
* Fix for failed first-ever logins on PostgreSQL where column default is nil (by github.com/bensie)
|
||||
* :default options is now honored in migrations
|
||||
|
||||
== 1.1.2
|
||||
|
||||
* bugfix
|
||||
* Compatibility with latest Rails routes schema
|
||||
|
||||
== 1.1.1
|
||||
|
||||
* bugfix
|
||||
* Fix a small bug where generated locale file was empty on devise:install
|
||||
|
||||
== 1.1.0
|
||||
|
||||
* enhancements
|
||||
* Rememberable module allows user to be remembered across browsers and is enabled by default (by github.com/trevorturk)
|
||||
* Rememberable module allows you to activate the period the remember me token is extended (by github.com/trevorturk)
|
||||
* devise_for can now be used together with scope method in routes but with a few limitations (check the documentation)
|
||||
* Support `as` or `devise_scope` in the router to specify controller access scope
|
||||
* HTTP Basic Auth can now be disabled/enabled for xhr(ajax) requests using http_authenticatable_on_xhr option (by github.com/pellja)
|
||||
|
||||
* bug fix
|
||||
* Fix a bug in Devise::TestHelpers where current_user was returning a Response object for non active accounts
|
||||
* Devise should respect script_name and path_info contracts
|
||||
* Fix a bug when accessing a path with (.:format) (by github.com/klacointe)
|
||||
* Do not add unlock routes unless unlock strategy is email or both
|
||||
* Email should be case insensitive
|
||||
* Store classes as string in session, to avoid serialization and stale data issues
|
||||
|
||||
* deprecations
|
||||
* use_default_scope is deprecated and has no effect. Use :as or :devise_scope in the router instead
|
||||
|
||||
== 1.1.rc2
|
||||
|
||||
* enhancements
|
||||
* Allow to set cookie domain for the remember token. (by github.com/mantas)
|
||||
* Added navigational formats to specify when it should return a 302 and when a 401.
|
||||
* Added authenticate(scope) support in routes (by github.com/wildchild)
|
||||
* Added after_update_path_for to registrations controller (by github.com/thedelchop)
|
||||
* Allow the mailer object to be replaced through config.mailer = "MyOwnMailer"
|
||||
|
||||
* bug fix
|
||||
* Fix a bug where session was timing out on sign out
|
||||
|
||||
* deprecations
|
||||
* bcrypt is now the default encryptor
|
||||
* devise.mailer.confirmations_instructions now should be devise.mailer.confirmations_instructions.subject
|
||||
* devise.mailer.user.confirmations_instructions now should be devise.mailer.confirmations_instructions.user_subject
|
||||
* Generators now use Rails 3 syntax (devise:install) instead of devise_install
|
||||
|
||||
== 1.1.rc1
|
||||
|
||||
* enhancements
|
||||
* Rails 3 compatibility
|
||||
* All controllers and views are namespaced, for example: Devise::SessionsController and "devise/sessions"
|
||||
* Devise.orm is deprecated. This reduces the required API to hook your ORM with devise
|
||||
* Use metal for failure app
|
||||
* HTML e-mails now have proper formatting
|
||||
* Allow to give :skip and :controllers in routes
|
||||
* Move trackable logic to the model
|
||||
* E-mails now use any template available in the filesystem. Easy to create multipart e-mails
|
||||
* E-mails asks headers_for in the model to set the proper headers
|
||||
* Allow to specify haml in devise_views
|
||||
* Compatibility with Mongoid
|
||||
* Make config.devise available on config/application.rb
|
||||
* TokenAuthenticatable now works with HTTP Basic Auth
|
||||
* Allow :unlock_strategy to be :none and add :lock_strategy which can be :failed_attempts or none. Setting those values to :none means that you want to handle lock and unlocking by yourself
|
||||
* No need to append ?unauthenticated=true in URLs anymore since Flash was moved to a middleware in Rails 3
|
||||
* :activatable is included by default in your models
|
||||
|
||||
* bug fix
|
||||
* Fix a bug with STI
|
||||
|
||||
* deprecations
|
||||
* Rails 3 compatible only
|
||||
* Removed support for MongoMapper
|
||||
* Scoped views are no longer "sessions/users/new". Now use "users/sessions/new"
|
||||
* Devise.orm is deprecated, just require "devise/orm/YOUR_ORM" instead
|
||||
* Devise.default_url_options is deprecated, just modify ApplicationController.default_url_options
|
||||
* All messages under devise.sessions, except :signed_in and :signed_out, should be moved to devise.failure
|
||||
* :as and :scope in routes is deprecated. Use :path and :singular instead
|
||||
|
||||
== 1.0.8
|
||||
|
||||
* enhancements
|
||||
* Support for latest MongoMapper
|
||||
* Added anybody_signed_in? helper (by github.com/SSDany)
|
||||
|
||||
* bug fix
|
||||
* confirmation_required? is properly honored on active? calls. (by github.com/paulrosania)
|
||||
|
||||
== 1.0.7
|
||||
|
||||
* bug fix
|
||||
* Ensure password confirmation is always required
|
||||
|
||||
* deprecations
|
||||
* authenticatable was deprecated and renamed to database_authenticatable
|
||||
* confirmable is not included by default on generation
|
||||
|
||||
== 1.0.6
|
||||
|
||||
* bug fix
|
||||
* Do not allow unlockable strategies based on time to access a controller.
|
||||
* Do not send unlockable email several times.
|
||||
* Allow controller to upstram custom! failures to Warden.
|
||||
|
||||
== 1.0.5
|
||||
|
||||
* bug fix
|
||||
* Use prepend_before_filter in require_no_authentication.
|
||||
* require_no_authentication on unlockable.
|
||||
* Fix a bug when giving an association proxy to devise.
|
||||
* Do not use lock! on lockable since it's part of ActiveRecord API.
|
||||
|
||||
== 1.0.4
|
||||
|
||||
* bug fix
|
||||
* Fixed a bug when deleting an account with rememberable
|
||||
* Fixed a bug with custom controllers
|
||||
|
||||
== 1.0.3
|
||||
|
||||
* enhancements
|
||||
* HTML e-mails now have proper formatting
|
||||
* Do not remove MongoMapper options in find
|
||||
|
||||
== 1.0.2
|
||||
|
||||
* enhancements
|
||||
* Allows you set mailer content type (by github.com/glennr)
|
||||
|
||||
* bug fix
|
||||
* Uses the same content type as request on http authenticatable 401 responses
|
||||
|
||||
== 1.0.1
|
||||
|
||||
* enhancements
|
||||
* HttpAuthenticatable is not added by default automatically.
|
||||
* Avoid mass assignment error messages with current password.
|
||||
|
||||
* bug fix
|
||||
* Fixed encryptors autoload
|
||||
|
||||
== 1.0.0
|
||||
|
||||
* deprecation
|
||||
* :old_password in update_with_password is deprecated, use :current_password instead
|
||||
|
||||
* enhancements
|
||||
* Added Registerable
|
||||
* Added Http Basic Authentication support
|
||||
* Allow scoped_views to be customized per controller/mailer class
|
||||
* [#99] Allow authenticatable to used in change_table statements
|
||||
|
||||
== 0.9.2
|
||||
|
||||
* bug fix
|
||||
* Ensure inactive user cannot sign in
|
||||
* Ensure redirect to proper url after sign up
|
||||
|
||||
* enhancements
|
||||
* Added gemspec to repo
|
||||
* Added token authenticatable (by github.com/grimen)
|
||||
|
||||
== 0.9.1
|
||||
|
||||
* bug fix
|
||||
* Allow bigger salt size (by github.com/jgeiger)
|
||||
* Fix relative url root
|
||||
|
||||
== 0.9.0
|
||||
|
||||
* deprecation
|
||||
* devise :all is deprecated
|
||||
* :success and :failure flash messages are now :notice and :alert
|
||||
|
||||
* enhancements
|
||||
* Added devise lockable (by github.com/mhfs)
|
||||
* Warden 0.9.0 compatibility
|
||||
* Mongomapper 0.6.10 compatibility
|
||||
* Added Devise.add_module as hooks for extensions (by github.com/grimen)
|
||||
* Ruby 1.9.1 compatibility (by github.com/grimen)
|
||||
|
||||
* bug fix
|
||||
* Accept path prefix not starting with slash
|
||||
* url helpers should rely on find_scope!
|
||||
|
||||
== 0.8.2
|
||||
|
||||
* enhancements
|
||||
* Allow Devise.mailer_sender to be a proc (by github.com/grimen)
|
||||
|
||||
* bug fix
|
||||
* Fix bug with passenger, update is required to anyone deploying on passenger (by github.com/dvdpalm)
|
||||
|
||||
== 0.8.1
|
||||
|
||||
* enhancements
|
||||
* Move salt to encryptors
|
||||
* Devise::Lockable
|
||||
* Moved view links into partial and I18n'ed them
|
||||
|
||||
* bug fix
|
||||
* Bcrypt generator was not being loaded neither setting the proper salt
|
||||
|
||||
== 0.8.0
|
||||
|
||||
* enhancements
|
||||
* Warden 0.8.0 compatibility
|
||||
* Add an easy for map.connect "sign_in", :controller => "sessions", :action => "new" to work
|
||||
* Added :bcrypt encryptor (by github.com/capotej)
|
||||
|
||||
* bug fix
|
||||
* sign_in_count is also increased when user signs in via password change, confirmation, etc..
|
||||
* More DataMapper compatibility (by github.com/lancecarlson)
|
||||
|
||||
* deprecation
|
||||
* Removed DeviseMailer.sender
|
||||
|
||||
== 0.7.5
|
||||
|
||||
* enhancements
|
||||
* Set a default value for mailer to avoid find_template issues
|
||||
* Add models configuration to MongoMapper::EmbeddedDocument as well
|
||||
|
||||
== 0.7.4
|
||||
|
||||
* enhancements
|
||||
* Extract Activatable from Confirmable
|
||||
* Decouple Serializers from Devise modules
|
||||
|
||||
== 0.7.3
|
||||
|
||||
* bug fix
|
||||
* Give scope to the proper model validation
|
||||
|
||||
* enhancements
|
||||
* Mail views are scoped as well
|
||||
* Added update_with_password for authenticatable
|
||||
* Allow render_with_scope to accept :controller option
|
||||
|
||||
== 0.7.2
|
||||
|
||||
* deprecation
|
||||
* Renamed reset_confirmation! to resend_confirmation!
|
||||
* Copying locale is part of the installation process
|
||||
|
||||
* bug fix
|
||||
* Fixed render_with_scope to work with all controllers
|
||||
* Allow sign in with two different users in Devise::TestHelpers
|
||||
|
||||
== 0.7.1
|
||||
|
||||
* enhancements
|
||||
* Small enhancements for other plugins compatibility (by github.com/grimen)
|
||||
|
||||
== 0.7.0
|
||||
|
||||
* deprecations
|
||||
* :authenticatable is not included by default anymore
|
||||
|
||||
* enhancements
|
||||
* Improve loading process
|
||||
* Extract SessionSerializer from Authenticatable
|
||||
|
||||
== 0.6.3
|
||||
|
||||
* bug fix
|
||||
* Added trackable to migrations
|
||||
* Allow inflections to work
|
||||
|
||||
== 0.6.2
|
||||
|
||||
* enhancements
|
||||
* More DataMapper compatibility
|
||||
* Devise::Trackable - track sign in count, timestamps and ips
|
||||
|
||||
== 0.6.1
|
||||
|
||||
* enhancements
|
||||
* Devise::Timeoutable - timeout sessions without activity
|
||||
* DataMapper now accepts conditions
|
||||
|
||||
== 0.6.0
|
||||
|
||||
* deprecations
|
||||
* :authenticatable is still included by default, but yields a deprecation warning
|
||||
|
||||
* enhancements
|
||||
* Added DataMapper support
|
||||
* Remove store_location from authenticatable strategy and add it to failure app
|
||||
* Allow a strategy to be placed after authenticatable
|
||||
* [#45] Do not rely attribute? methods, since they are not added on Datamapper
|
||||
|
||||
== 0.5.6
|
||||
|
||||
* enhancements
|
||||
* [#42] Do not send nil to build (DataMapper compatibility)
|
||||
* [#44] Allow to have scoped views
|
||||
|
||||
== 0.5.5
|
||||
|
||||
* enhancements
|
||||
* Allow overwriting find for authentication method
|
||||
* [#38] Remove Ruby 1.8.7 dependency
|
||||
|
||||
== 0.5.4
|
||||
|
||||
* deprecations
|
||||
* Deprecate :singular in devise_for and use :scope instead
|
||||
|
||||
* enhancements
|
||||
* [#37] Create after_sign_in_path_for and after_sign_out_path_for hooks to be
|
||||
overwriten in ApplicationController
|
||||
* Create sign_in_and_redirect and sign_out_and_redirect helpers
|
||||
* Warden::Manager.default_scope is automatically configured to the first given scope
|
||||
|
||||
== 0.5.3
|
||||
|
||||
* bug fix
|
||||
* MongoMapper now converts DateTime to Time
|
||||
* Ensure all controllers are unloadable
|
||||
|
||||
* enhancements
|
||||
* [#35] Moved friendly_token to Devise
|
||||
* Added Devise.all, so you can freeze your app strategies
|
||||
* Added Devise.apply_schema, so you can turn it to false in Datamapper or MongoMapper
|
||||
in cases you don't want it be handlded automatically
|
||||
|
||||
== 0.5.2
|
||||
|
||||
* enhancements
|
||||
* [#28] Improved sign_in and sign_out helpers to accepts resources
|
||||
* [#28] Added stored_location_for as a helper
|
||||
* [#20] Added test helpers
|
||||
|
||||
== 0.5.1
|
||||
|
||||
* enhancements
|
||||
* Added serializers based on Warden ones
|
||||
* Allow authentication keys to be set
|
||||
|
||||
== 0.5.0
|
||||
|
||||
* bug fix
|
||||
* Fixed a bug where remember me module was not working properly
|
||||
|
||||
* enhancements
|
||||
* Moved encryption strategy into the Encryptors module to allow several algorithms (by github.com/mhfs)
|
||||
* Implemented encryptors for Clearance, Authlogic and Restful-Authentication (by github.com/mhfs)
|
||||
* Added support for MongoMapper (by github.com/shingara)
|
||||
|
||||
== 0.4.3
|
||||
|
||||
* bug fix
|
||||
* [#29] Authentication just fails if user cannot be serialized from session, without raising errors;
|
||||
* Default configuration values should not overwrite user values;
|
||||
|
||||
== 0.4.2
|
||||
|
||||
* deprecations
|
||||
* Renamed mail_sender to mailer_sender
|
||||
|
||||
* enhancements
|
||||
* skip_before_filter added in Devise controllers
|
||||
* Use home_or_root_path on require_no_authentication as well
|
||||
* Added devise_controller?, useful to select or reject filters in ApplicationController
|
||||
* Allow :path_prefix to be given to devise_for
|
||||
* Allow default_url_options to be configured through devise (:path_prefix => "/:locale" is now supported)
|
||||
|
||||
== 0.4.1
|
||||
|
||||
* bug fix
|
||||
* [#21] Ensure options can be set even if models were not loaded
|
||||
|
||||
== 0.4.0
|
||||
|
||||
* deprecations
|
||||
* Notifier is deprecated, use DeviseMailer instead. Remember to rename
|
||||
app/views/notifier to app/views/devise_mailer and I18n key from
|
||||
devise.notifier to devise.mailer
|
||||
* :authenticable calls are deprecated, use :authenticatable instead
|
||||
|
||||
* enhancements
|
||||
* [#16] Allow devise to be more agnostic and do not require ActiveRecord to be loaded
|
||||
* Allow Warden::Manager to be configured through Devise
|
||||
* Created a generator which creates an initializer
|
||||
|
||||
== 0.3.0
|
||||
|
||||
* bug fix
|
||||
* [#15] Allow yml messages to be configured by not using engine locales
|
||||
|
||||
* deprecations
|
||||
* Renamed confirm_in to confirm_within
|
||||
* [#14] Do not send confirmation messages when user changes his e-mail
|
||||
* [#13] Renamed authenticable to authenticatable and added deprecation warnings
|
||||
|
||||
== 0.2.3
|
||||
|
||||
* enhancements
|
||||
* Ensure fail! works inside strategies
|
||||
* [#12] Make unauthenticated message (when you haven't signed in) different from invalid message
|
||||
|
||||
* bug fix
|
||||
* Do not redirect on invalid authenticate
|
||||
* Allow model configuration to be set to nil
|
||||
|
||||
== 0.2.2
|
||||
|
||||
* bug fix
|
||||
* [#9] Fix a bug when using customized resources
|
||||
|
||||
== 0.2.1
|
||||
|
||||
* refactor
|
||||
* Clean devise_views generator to use devise existing views
|
||||
|
||||
* enhancements
|
||||
* [#7] Create instance variables (like @user) for each devise controller
|
||||
* Use Devise::Controller::Helpers only internally
|
||||
|
||||
* bug fix
|
||||
* [#6] Fix a bug with Mongrel and Ruby 1.8.6
|
||||
|
||||
== 0.2.0
|
||||
|
||||
* enhancements
|
||||
* [#4] Allow option :null => true in authenticable migration
|
||||
* [#3] Remove attr_accessible calls from devise modules
|
||||
* Customizable time frame for rememberable with :remember_for config
|
||||
* Customizable time frame for confirmable with :confirm_in config
|
||||
* Generators for creating a resource and copy views
|
||||
|
||||
* optimize
|
||||
* Do not load hooks or strategies if they are not used
|
||||
|
||||
* bug fixes
|
||||
* [#2] Fixed requiring devise strategies
|
||||
|
||||
== 0.1.1
|
||||
|
||||
* bug fixes
|
||||
* [#1] Fixed requiring devise mapping
|
||||
|
||||
== 0.1.0
|
||||
|
||||
* Devise::Authenticable
|
||||
* Devise::Confirmable
|
||||
* Devise::Recoverable
|
||||
* Devise::Validatable
|
||||
* Devise::Migratable
|
||||
* Devise::Rememberable
|
||||
|
||||
* SessionsController
|
||||
* PasswordsController
|
||||
* ConfirmationsController
|
||||
|
||||
* Create an example app
|
||||
* devise :all, :except => :rememberable
|
||||
* Use sign_in and sign_out in SessionsController
|
||||
|
||||
* Mailer subjects namespaced by model
|
||||
* Allow stretches and pepper per model
|
||||
|
||||
* Store session[:return_to] in session
|
||||
* Sign user in automatically after confirming or changing it's password
|
||||
14
CONTRIBUTING.md
Normal file
14
CONTRIBUTING.md
Normal file
@@ -0,0 +1,14 @@
|
||||
### Please read before contributing
|
||||
|
||||
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).
|
||||
|
||||
2) If you find a security bug, **DO NOT** submit an issue here. Please send an e-mail to [opensource@plataformatec.com.br](mailto:opensource@plataformatec.com.br) instead.
|
||||
|
||||
3) Do a small search on the issues tracker before submitting your issue to see if it was already reported / fixed.
|
||||
|
||||
4) When reporting an issue, include Rails, Devise and Warden versions. If you are getting exceptions, please include the full backtrace.
|
||||
|
||||
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.
|
||||
|
||||
Thanks!
|
||||
34
Gemfile
34
Gemfile
@@ -1,29 +1,29 @@
|
||||
source "http://rubygems.org"
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec
|
||||
|
||||
gem "rails", "~> 3.0.4"
|
||||
gem "oa-oauth", '~> 0.2.0', :require => "omniauth/oauth"
|
||||
gem "oa-openid", '~> 0.2.0', :require => "omniauth/openid"
|
||||
gem "rails", "4.2.1"
|
||||
gem "omniauth", "~> 1.2.0"
|
||||
gem "omniauth-oauth2", "~> 1.1.0"
|
||||
gem "rdoc"
|
||||
|
||||
group :test do
|
||||
gem "webrat", "0.7.2", :require => false
|
||||
gem "mocha", :require => false
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
end
|
||||
|
||||
platforms :jruby do
|
||||
gem 'activerecord-jdbcsqlite3-adapter'
|
||||
gem "activerecord-jdbc-adapter"
|
||||
gem "activerecord-jdbcsqlite3-adapter"
|
||||
gem "jruby-openssl"
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
group :test do
|
||||
gem "sqlite3-ruby"
|
||||
gem "ruby-debug", ">= 0.10.3" if RUBY_VERSION < '1.9'
|
||||
end
|
||||
|
||||
group :mongoid do
|
||||
gem "mongo", "1.1.2"
|
||||
gem "mongoid", "2.0.0.beta.20"
|
||||
gem "bson_ext", "1.2.1"
|
||||
end
|
||||
gem "sqlite3"
|
||||
end
|
||||
|
||||
group :mongoid do
|
||||
gem "mongoid", github: "mongoid/mongoid", branch: "master"
|
||||
end
|
||||
|
||||
309
Gemfile.lock
309
Gemfile.lock
@@ -1,158 +1,191 @@
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
devise (1.2.rc)
|
||||
bcrypt-ruby (~> 2.1.2)
|
||||
orm_adapter (~> 0.0.3)
|
||||
warden (~> 1.0.3)
|
||||
devise (3.5.0)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 3.2.6, < 5)
|
||||
responders
|
||||
thread_safe (~> 0.1)
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/mongoid/mongoid.git
|
||||
revision: a4365d7ecfa8221bfcf36a4e7ce7993142fc5940
|
||||
branch: master
|
||||
specs:
|
||||
mongoid (4.0.0)
|
||||
activemodel (~> 4.0)
|
||||
moped (~> 2.0.0)
|
||||
origin (~> 2.1)
|
||||
tzinfo (>= 0.3.37)
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
abstract (1.0.0)
|
||||
actionmailer (3.0.4)
|
||||
actionpack (= 3.0.4)
|
||||
mail (~> 2.2.15)
|
||||
actionpack (3.0.4)
|
||||
activemodel (= 3.0.4)
|
||||
activesupport (= 3.0.4)
|
||||
builder (~> 2.1.2)
|
||||
erubis (~> 2.6.6)
|
||||
i18n (~> 0.4)
|
||||
rack (~> 1.2.1)
|
||||
rack-mount (~> 0.6.13)
|
||||
rack-test (~> 0.5.7)
|
||||
tzinfo (~> 0.3.23)
|
||||
activemodel (3.0.4)
|
||||
activesupport (= 3.0.4)
|
||||
builder (~> 2.1.2)
|
||||
i18n (~> 0.4)
|
||||
activerecord (3.0.4)
|
||||
activemodel (= 3.0.4)
|
||||
activesupport (= 3.0.4)
|
||||
arel (~> 2.0.2)
|
||||
tzinfo (~> 0.3.23)
|
||||
activerecord-jdbc-adapter (1.1.1)
|
||||
activerecord-jdbcsqlite3-adapter (1.1.1)
|
||||
activerecord-jdbc-adapter (= 1.1.1)
|
||||
jdbc-sqlite3 (~> 3.6.0)
|
||||
activeresource (3.0.4)
|
||||
activemodel (= 3.0.4)
|
||||
activesupport (= 3.0.4)
|
||||
activesupport (3.0.4)
|
||||
addressable (2.2.4)
|
||||
arel (2.0.8)
|
||||
bcrypt-ruby (2.1.4)
|
||||
bson (1.2.1)
|
||||
bson_ext (1.2.1)
|
||||
builder (2.1.2)
|
||||
columnize (0.3.2)
|
||||
erubis (2.6.6)
|
||||
abstract (>= 1.0.0)
|
||||
faraday (0.5.7)
|
||||
addressable (~> 2.2.4)
|
||||
multipart-post (~> 1.1.0)
|
||||
rack (>= 1.1.0, < 2)
|
||||
i18n (0.5.0)
|
||||
jdbc-sqlite3 (3.6.14.2.056-java)
|
||||
linecache (0.43)
|
||||
mail (2.2.15)
|
||||
activesupport (>= 2.3.6)
|
||||
i18n (>= 0.4.0)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
mime-types (1.16)
|
||||
mocha (0.9.12)
|
||||
mongo (1.1.2)
|
||||
bson (>= 1.1.1)
|
||||
mongoid (2.0.0.beta.20)
|
||||
activemodel (~> 3.0)
|
||||
mongo (~> 1.1)
|
||||
tzinfo (~> 0.3.22)
|
||||
will_paginate (~> 3.0.pre)
|
||||
multi_json (0.0.5)
|
||||
multipart-post (1.1.0)
|
||||
nokogiri (1.4.4)
|
||||
nokogiri (1.4.4-java)
|
||||
weakling (>= 0.0.3)
|
||||
oa-core (0.2.0)
|
||||
rack (~> 1.1)
|
||||
oa-oauth (0.2.0)
|
||||
multi_json (~> 0.0.2)
|
||||
nokogiri (~> 1.4.2)
|
||||
oa-core (= 0.2.0)
|
||||
oauth (~> 0.4.0)
|
||||
oauth2 (~> 0.1.1)
|
||||
oa-openid (0.2.0)
|
||||
oa-core (= 0.2.0)
|
||||
rack-openid (~> 1.2.0)
|
||||
ruby-openid-apps-discovery
|
||||
oauth (0.4.4)
|
||||
oauth2 (0.1.1)
|
||||
faraday (~> 0.5.0)
|
||||
multi_json (~> 0.0.4)
|
||||
orm_adapter (0.0.4)
|
||||
polyglot (0.3.1)
|
||||
rack (1.2.1)
|
||||
rack-mount (0.6.13)
|
||||
rack (>= 1.0.0)
|
||||
rack-openid (1.2.0)
|
||||
actionmailer (4.2.1)
|
||||
actionpack (= 4.2.1)
|
||||
actionview (= 4.2.1)
|
||||
activejob (= 4.2.1)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
actionpack (4.2.1)
|
||||
actionview (= 4.2.1)
|
||||
activesupport (= 4.2.1)
|
||||
rack (~> 1.6)
|
||||
rack-test (~> 0.6.2)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
||||
actionview (4.2.1)
|
||||
activesupport (= 4.2.1)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
||||
activejob (4.2.1)
|
||||
activesupport (= 4.2.1)
|
||||
globalid (>= 0.3.0)
|
||||
activemodel (4.2.1)
|
||||
activesupport (= 4.2.1)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.2.1)
|
||||
activemodel (= 4.2.1)
|
||||
activesupport (= 4.2.1)
|
||||
arel (~> 6.0)
|
||||
activesupport (4.2.1)
|
||||
i18n (~> 0.7)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
arel (6.0.0)
|
||||
bcrypt (3.1.10)
|
||||
bson (2.3.0)
|
||||
builder (3.2.2)
|
||||
connection_pool (2.1.3)
|
||||
erubis (2.7.0)
|
||||
faraday (0.9.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.3.3)
|
||||
activesupport (>= 4.1.0)
|
||||
hashie (3.4.0)
|
||||
hike (1.2.3)
|
||||
i18n (0.7.0)
|
||||
json (1.8.2)
|
||||
jwt (1.4.1)
|
||||
loofah (2.0.1)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
metaclass (0.0.4)
|
||||
mime-types (2.4.3)
|
||||
mini_portile (0.6.2)
|
||||
minitest (5.5.1)
|
||||
mocha (1.1.0)
|
||||
metaclass (~> 0.0.1)
|
||||
moped (2.0.4)
|
||||
bson (~> 2.2)
|
||||
connection_pool (~> 2.0)
|
||||
optionable (~> 0.2.0)
|
||||
multi_json (1.11.0)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.6.6.2)
|
||||
mini_portile (~> 0.6.0)
|
||||
oauth2 (0.9.4)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
jwt (~> 1.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (~> 1.2)
|
||||
omniauth (1.2.2)
|
||||
hashie (>= 1.2, < 4)
|
||||
rack (~> 1.0)
|
||||
omniauth-facebook (1.6.0)
|
||||
omniauth-oauth2 (~> 1.1)
|
||||
omniauth-oauth2 (1.1.2)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
multi_json (~> 1.3)
|
||||
oauth2 (~> 0.9.3)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
optionable (0.2.0)
|
||||
origin (2.1.1)
|
||||
orm_adapter (0.5.0)
|
||||
rack (1.6.0)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.5.7)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (3.0.4)
|
||||
actionmailer (= 3.0.4)
|
||||
actionpack (= 3.0.4)
|
||||
activerecord (= 3.0.4)
|
||||
activeresource (= 3.0.4)
|
||||
activesupport (= 3.0.4)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.0.4)
|
||||
railties (3.0.4)
|
||||
actionpack (= 3.0.4)
|
||||
activesupport (= 3.0.4)
|
||||
rails (4.2.1)
|
||||
actionmailer (= 4.2.1)
|
||||
actionpack (= 4.2.1)
|
||||
actionview (= 4.2.1)
|
||||
activejob (= 4.2.1)
|
||||
activemodel (= 4.2.1)
|
||||
activerecord (= 4.2.1)
|
||||
activesupport (= 4.2.1)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.2.1)
|
||||
sprockets-rails
|
||||
rails-deprecated_sanitizer (1.0.3)
|
||||
activesupport (>= 4.2.0.alpha)
|
||||
rails-dom-testing (1.0.6)
|
||||
activesupport (>= 4.2.0.beta, < 5.0)
|
||||
nokogiri (~> 1.6.0)
|
||||
rails-deprecated_sanitizer (>= 1.0.1)
|
||||
rails-html-sanitizer (1.0.2)
|
||||
loofah (~> 2.0)
|
||||
railties (4.2.1)
|
||||
actionpack (= 4.2.1)
|
||||
activesupport (= 4.2.1)
|
||||
rake (>= 0.8.7)
|
||||
thor (~> 0.14.4)
|
||||
rake (0.8.7)
|
||||
ruby-debug (0.10.4)
|
||||
columnize (>= 0.1)
|
||||
ruby-debug-base (~> 0.10.4.0)
|
||||
ruby-debug-base (0.10.4)
|
||||
linecache (>= 0.3)
|
||||
ruby-openid (2.1.8)
|
||||
ruby-openid-apps-discovery (1.2.0)
|
||||
ruby-openid (>= 2.1.7)
|
||||
sqlite3 (1.3.3)
|
||||
sqlite3-ruby (1.3.3)
|
||||
sqlite3 (>= 1.3.3)
|
||||
thor (0.14.6)
|
||||
treetop (1.4.9)
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.24)
|
||||
warden (1.0.3)
|
||||
rack (>= 1.0.0)
|
||||
weakling (0.0.4-java)
|
||||
webrat (0.7.2)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (10.4.2)
|
||||
rdoc (4.2.0)
|
||||
responders (2.1.0)
|
||||
railties (>= 4.2.0, < 5)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (2.12.3)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
sprockets-rails (2.2.4)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sqlite3 (1.3.10)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tilt (1.4.1)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.3)
|
||||
rack (>= 1.0)
|
||||
webrat (0.7.3)
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
will_paginate (3.0.pre2)
|
||||
|
||||
PLATFORMS
|
||||
java
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activerecord-jdbc-adapter
|
||||
activerecord-jdbcsqlite3-adapter
|
||||
bson_ext (= 1.2.1)
|
||||
devise!
|
||||
mocha
|
||||
mongo (= 1.1.2)
|
||||
mongoid (= 2.0.0.beta.20)
|
||||
oa-oauth (~> 0.2.0)
|
||||
oa-openid (~> 0.2.0)
|
||||
rails (~> 3.0.4)
|
||||
ruby-debug (>= 0.10.3)
|
||||
sqlite3-ruby
|
||||
webrat (= 0.7.2)
|
||||
jruby-openssl
|
||||
mocha (~> 1.1)
|
||||
mongoid!
|
||||
omniauth (~> 1.2.0)
|
||||
omniauth-facebook
|
||||
omniauth-oauth2 (~> 1.1.0)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
rails (= 4.2.1)
|
||||
rdoc
|
||||
sqlite3
|
||||
webrat (= 0.7.3)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright 2009-2011 Plataforma Tecnologia. http://blog.plataformatec.com.br
|
||||
Copyright 2009-2015 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
|
||||
|
||||
549
README.md
Normal file
549
README.md
Normal file
@@ -0,0 +1,549 @@
|
||||

|
||||
|
||||
By [Plataformatec](http://plataformatec.com.br/).
|
||||
|
||||
[](http://travis-ci.org/plataformatec/devise)
|
||||
[](https://codeclimate.com/github/plataformatec/devise)
|
||||
[](https://hakiri.io/github/plataformatec/devise/master)
|
||||
|
||||
This README is [also available in a friendly navigable format](http://devise.plataformatec.com.br/).
|
||||
|
||||
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 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 not been active 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.
|
||||
|
||||
Devise is guaranteed to be thread-safe on YARV. Thread-safety support on JRuby is in progress.
|
||||
|
||||
## Information
|
||||
|
||||
### The Devise wiki
|
||||
|
||||
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://github.com/plataformatec/devise/wiki
|
||||
|
||||
### Bug reports
|
||||
|
||||
If you discover a problem with Devise, we would like to know about it. However, we ask that you please review these guidelines before submitting a bug report:
|
||||
|
||||
https://github.com/plataformatec/devise/wiki/Bug-reports
|
||||
|
||||
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
|
||||
|
||||
If you have any questions, comments, or concerns, please use the Google Group instead of the GitHub issue tracker:
|
||||
|
||||
https://groups.google.com/group/plataformatec-devise
|
||||
|
||||
### RDocs
|
||||
|
||||
You can view the Devise documentation in RDoc format here:
|
||||
|
||||
http://rubydoc.info/github/plataformatec/devise/master/frames
|
||||
|
||||
If you need to use Devise with previous versions of Rails, you can always run "gem server" from the command line after you install the gem to access the old documentation.
|
||||
|
||||
### Example applications
|
||||
|
||||
There are a few example applications available on GitHub that demonstrate various features of Devise with different versions of Rails. You can view them here:
|
||||
|
||||
https://github.com/plataformatec/devise/wiki/Example-Applications
|
||||
|
||||
### Extensions
|
||||
|
||||
Our community has created a number of extensions that add functionality above and beyond what is included with Devise. You can view a list of available extensions and add your own here:
|
||||
|
||||
https://github.com/plataformatec/devise/wiki/Extensions
|
||||
|
||||
### Contributing
|
||||
|
||||
We hope that you will consider contributing to Devise. Please read this short overview for some information about how to get started:
|
||||
|
||||
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.
|
||||
|
||||
## Starting with Rails?
|
||||
|
||||
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 two resources that should help you get started:
|
||||
|
||||
* Michael Hartl's online book: https://www.railstutorial.org/book/modeling_users
|
||||
* Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-from-scratch
|
||||
|
||||
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:
|
||||
|
||||
```ruby
|
||||
gem 'devise'
|
||||
```
|
||||
|
||||
Run the bundle command to install it.
|
||||
|
||||
After you install Devise and add it to your Gemfile, you need to run the generator:
|
||||
|
||||
```console
|
||||
rails generate devise:install
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```console
|
||||
rails generate devise MODEL
|
||||
```
|
||||
|
||||
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 default Devise modules. The 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. Then run `rake db:migrate`
|
||||
|
||||
Next, you 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 }
|
||||
```
|
||||
|
||||
You should restart your application after changing Devise's configuration options. 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_action (assuming your devise model is 'User'):
|
||||
|
||||
```ruby
|
||||
before_action :authenticate_user!
|
||||
```
|
||||
|
||||
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
|
||||
user_signed_in?
|
||||
```
|
||||
|
||||
For the current signed-in user, this helper is available:
|
||||
|
||||
```ruby
|
||||
current_user
|
||||
```
|
||||
|
||||
You can access the session for this scope:
|
||||
|
||||
```ruby
|
||||
user_session
|
||||
```
|
||||
|
||||
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"
|
||||
```
|
||||
|
||||
You can also override `after_sign_in_path_for` and `after_sign_out_path_for` to customize your redirect hooks.
|
||||
|
||||
Notice that if your Devise model is called `Member` instead of `User`, for example, then the helpers available are:
|
||||
|
||||
```ruby
|
||||
before_action :authenticate_member!
|
||||
|
||||
member_signed_in?
|
||||
|
||||
current_member
|
||||
|
||||
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:
|
||||
|
||||
```ruby
|
||||
devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 20
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
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 permitted parameters by default are:
|
||||
|
||||
* `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 so using a simple before filter in your `ApplicationController`:
|
||||
|
||||
```ruby
|
||||
class ApplicationController < ActionController::Base
|
||||
before_action :configure_permitted_parameters, if: :devise_controller?
|
||||
|
||||
protected
|
||||
|
||||
def configure_permitted_parameters
|
||||
devise_parameter_sanitizer.for(:sign_up) << :username
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
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. 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.for(:sign_in) { |u| u.permit(:username, :email) }
|
||||
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.for(:sign_up) { |u| u.permit({ roles: [] }, :email, :password, :password_confirmation) }
|
||||
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)
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
And then configure your controllers to use it:
|
||||
|
||||
```ruby
|
||||
class ApplicationController < ActionController::Base
|
||||
protected
|
||||
|
||||
def devise_parameter_sanitizer
|
||||
if resource_class == User
|
||||
User::ParameterSanitizer.new(User, :user, params)
|
||||
else
|
||||
super # Use the default one
|
||||
end
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
The example above overrides the permitted parameters for the user to be both `:username` and `:email`. The non-lazy way to configure parameters would be by defining the before filter above in a custom controller. We detail how to configure and customize controllers in some sections below.
|
||||
|
||||
### Configuring views
|
||||
|
||||
We built Devise to help you quickly develop an application that uses authentication. However, we don't want to be in your way when you need to customize it.
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```console
|
||||
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 controllers using the generator which requires a scope:
|
||||
|
||||
```console
|
||||
rails generate devise:controllers [scope]
|
||||
```
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
2. Tell the router to use this controller:
|
||||
|
||||
```ruby
|
||||
devise_for :users, controllers: { sessions: "users/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`.
|
||||
|
||||
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' }
|
||||
```
|
||||
|
||||
Be sure to check `devise_for` documentation 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:
|
||||
|
||||
```ruby
|
||||
devise_scope :user do
|
||||
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.
|
||||
|
||||
### I18n
|
||||
|
||||
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:
|
||||
devise:
|
||||
sessions:
|
||||
signed_in: 'Signed in successfully.'
|
||||
```
|
||||
|
||||
You can also create distinct messages based on the resource you've configured using the singular name given in routes:
|
||||
|
||||
```yaml
|
||||
en:
|
||||
devise:
|
||||
sessions:
|
||||
user:
|
||||
signed_in: 'Welcome user, you are signed in.'
|
||||
admin:
|
||||
signed_in: 'Hello admin!'
|
||||
```
|
||||
|
||||
The Devise mailer uses a similar pattern to create subject messages:
|
||||
|
||||
```yaml
|
||||
en:
|
||||
devise:
|
||||
mailer:
|
||||
confirmation_instructions:
|
||||
subject: 'Hello everybody!'
|
||||
user_subject: 'Hello User! Please confirm your email'
|
||||
reset_password_instructions:
|
||||
subject: 'Reset instructions'
|
||||
```
|
||||
|
||||
Take a look at our locale file to check all available messages. You may also be interested in one of the many translations that are available on our wiki:
|
||||
|
||||
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 test 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:
|
||||
|
||||
```ruby
|
||||
class ActionController::TestCase
|
||||
include Devise::TestHelpers
|
||||
end
|
||||
```
|
||||
|
||||
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
|
||||
end
|
||||
```
|
||||
|
||||
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. Such methods have the same signature as in controllers:
|
||||
|
||||
```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)
|
||||
```
|
||||
|
||||
There are two things that are 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 the router, but since functional 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
|
||||
@request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
get :new
|
||||
```
|
||||
|
||||
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-3-and-4-%28and-RSpec%29
|
||||
|
||||
### 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
|
||||
|
||||
### Configuring multiple models
|
||||
|
||||
Devise allows you to set up as many Devise models as you want. If you want to have an Admin model with just authentication and timeout features, in addition to the User model above, just run:
|
||||
|
||||
```ruby
|
||||
# Create a migration with the required fields
|
||||
create_table :admins do |t|
|
||||
t.string :email
|
||||
t.string :encrypted_password
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
# Inside your Admin model
|
||||
devise :database_authenticatable, :timeoutable
|
||||
|
||||
# Inside your routes
|
||||
devise_for :admins
|
||||
|
||||
# Inside your protected controller
|
||||
before_filter :authenticate_admin!
|
||||
|
||||
# Inside your controllers and views
|
||||
admin_signed_in?
|
||||
current_admin
|
||||
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 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 select another ORM, simply require it in the initializer file.
|
||||
|
||||
## Additional information
|
||||
|
||||
### Heroku
|
||||
|
||||
Using Devise on Heroku with Ruby on Rails 3.2 requires setting:
|
||||
|
||||
```ruby
|
||||
config.assets.initialize_on_precompile = false
|
||||
```
|
||||
|
||||
Read more about the potential issues at http://guides.rubyonrails.org/asset_pipeline.html
|
||||
|
||||
### Warden
|
||||
|
||||
Devise is based on Warden, which is a general Rack authentication framework created by Daniel Neighman. We encourage you to read more about Warden here:
|
||||
|
||||
https://github.com/hassox/warden
|
||||
|
||||
### Contributors
|
||||
|
||||
We have a long list of valued contributors. Check them all at:
|
||||
|
||||
https://github.com/plataformatec/devise/graphs/contributors
|
||||
|
||||
## License
|
||||
|
||||
MIT License. Copyright 2009-2015 Plataformatec. http://plataformatec.com.br
|
||||
|
||||
You are not granted rights or licenses to the trademarks of Plataformatec, including without limitation the Devise name or logo.
|
||||
362
README.rdoc
362
README.rdoc
@@ -1,362 +0,0 @@
|
||||
== Devise
|
||||
|
||||
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 roles (or models/scopes) signed in at the same time;
|
||||
* Is based on a modularity concept: use just what you really need.
|
||||
|
||||
It's composed of 12 modules:
|
||||
|
||||
* Database Authenticatable: 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.
|
||||
* Token Authenticatable: signs in a user based on an authentication token (also known as "single access token"). The token can be given both through query string or HTTP Basic Authentication.
|
||||
* Omniauthable: adds Omniauth (github.com/intridea/omniauth) support;
|
||||
* Confirmable: sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
|
||||
* Recoverable: resets the user password and sends reset instructions.
|
||||
* Registerable: handles signing up users through a registration process, also allowing them to edit and destroy their account.
|
||||
* Rememberable: manages generating and clearing a token for remembering the user from a saved cookie.
|
||||
* Trackable: tracks sign in count, timestamps and IP address.
|
||||
* Timeoutable: expires sessions that have no activity in a specified period of time.
|
||||
* Validatable: provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
|
||||
* Lockable: locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
|
||||
* Encryptable: adds support of other authentication mechanisms besides the built-in Bcrypt (the default).
|
||||
|
||||
== Information
|
||||
|
||||
=== The Devise wiki
|
||||
|
||||
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:
|
||||
|
||||
http://wiki.github.com/plataformatec/devise
|
||||
|
||||
=== Bug reports
|
||||
|
||||
If you discover a problem with Devise, we would like to know about it. However, we ask that you please review these guidelines before submitting a bug report:
|
||||
|
||||
http://github.com/plataformatec/devise/wiki/Bug-reports
|
||||
|
||||
If you found a security bug, do *NOT* use the GitHub issue tracker. Send email or a private GitHub message to the maintainers listed at the bottom of the README.
|
||||
|
||||
=== Mailing list
|
||||
|
||||
If you have any questions, comments, or concerns, please use the Google Group instead of the GitHub issue tracker:
|
||||
|
||||
http://groups.google.com/group/plataformatec-devise
|
||||
|
||||
=== RDocs
|
||||
|
||||
You can view the Devise documentation in RDoc format here:
|
||||
|
||||
http://rubydoc.info/github/plataformatec/devise/master/frames
|
||||
|
||||
If you need to use Devise with Rails 2.3, you can always run `gem server` from the command line after you install the gem to access the old documentation.
|
||||
|
||||
=== Example applications
|
||||
|
||||
There are a few example applications available on GitHub that demonstrate various features of Devise with different versions of Rails. You can view them here:
|
||||
|
||||
http://github.com/plataformatec/devise/wiki/Example-Applications
|
||||
|
||||
=== Extensions
|
||||
|
||||
Our community has created a number of extensions that add functionality above and beyond what is included with Devise. You can view a list of available extensions and add your own here:
|
||||
|
||||
http://github.com/plataformatec/devise/wiki/Extensions
|
||||
|
||||
=== Contributing
|
||||
|
||||
We hope that you will consider contributing to Devise. Please read this short overview for some information about how to get started:
|
||||
|
||||
http://github.com/plataformatec/devise/wiki/Contributing
|
||||
|
||||
You will usually want to write tests for your changes. To run the test suite, `cd` 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 1.6 or newer) running on your system.
|
||||
|
||||
== Installation
|
||||
|
||||
You can use the latest Rails 3 gem with the latest Devise gem:
|
||||
|
||||
gem install devise
|
||||
|
||||
After you install Devise and add it to your Gemfile, you need to run the generator:
|
||||
|
||||
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:
|
||||
|
||||
rails generate devise MODEL
|
||||
|
||||
Replace MODEL by the class name you want to add devise, like User, Admin, etc. This will create a model (if one does not exist) and configure it with default Devise modules. The generator will also create a migration file (if your ORM support them) and configure your routes. Continue reading this file to understand exactly what the generator produces and how to use it.
|
||||
|
||||
Support for Rails 2.3.x can be found by installing Devise 1.0.x from the v1.0 branch.
|
||||
|
||||
== 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:
|
||||
|
||||
* Michael Hartl's online book: http://railstutorial.org/chapters/modeling-and-viewing-users-two#top
|
||||
* Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-from-scratch
|
||||
|
||||
Once you have solidified you understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :)
|
||||
|
||||
== Getting started
|
||||
|
||||
This is a walkthrough with all steps you need to setup a devise resource, including model, migration, route files, and optional configuration.
|
||||
|
||||
Devise must be set up within the model (or models) you want to use. Devise routes must be created inside your config/routes.rb file.
|
||||
|
||||
We're assuming here you want a User model with some Devise modules, as outlined below:
|
||||
|
||||
class User < ActiveRecord::Base
|
||||
devise :database_authenticatable, :confirmable, :recoverable, :rememberable, :trackable, :validatable
|
||||
end
|
||||
|
||||
After you choose which modules to use, you need to set up your migrations. Luckily, Devise has some helpers to save you from this boring work:
|
||||
|
||||
create_table :users do |t|
|
||||
t.database_authenticatable
|
||||
t.confirmable
|
||||
t.recoverable
|
||||
t.rememberable
|
||||
t.trackable
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
Devise doesn't use _attr_accessible_ or _attr_protected_ inside its modules, so be sure to define attributes as accessible or protected in your model.
|
||||
|
||||
Configure your routes after setting up your model. Open your config/routes.rb file and add:
|
||||
|
||||
devise_for :users
|
||||
|
||||
This will use your User model to create a set of needed routes (you can see them by running `rake routes`). If you invoked the devise generator, you noticed that this is exactly what the generator produces for us: model, routes and migrations.
|
||||
|
||||
Don't forget to run rake db:migrate and you are ready to go! But don't stop reading here, we still have a lot to tell you.
|
||||
|
||||
=== 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:
|
||||
|
||||
before_filter :authenticate_user!
|
||||
|
||||
To verify if a user is signed in, use the following helper:
|
||||
|
||||
user_signed_in?
|
||||
|
||||
For the current signed-in user, this helper is available:
|
||||
|
||||
current_user
|
||||
|
||||
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:
|
||||
|
||||
root :to => "home"
|
||||
|
||||
You can also overwrite 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:
|
||||
|
||||
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:
|
||||
|
||||
before_filter :authenticate_member!
|
||||
|
||||
member_signed_in?
|
||||
|
||||
current_member
|
||||
|
||||
member_session
|
||||
|
||||
=== Configuring Models
|
||||
|
||||
The devise method in your models also accepts some options to configure its modules. For example, you can choose which encryptor to use in database_authenticatable:
|
||||
|
||||
devise :database_authenticatable, :confirmable, :recoverable, :stretches => 20
|
||||
|
||||
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.
|
||||
|
||||
=== Configuring multiple models
|
||||
|
||||
Devise allows you to set up as many roles as you want. For example, you may have a User model and also want an Admin model with just authentication, trackable, lockable and timeoutable features and no confirmation or password-recovery features. Just follow these steps:
|
||||
|
||||
# Create a migration with the required fields
|
||||
create_table :admins do |t|
|
||||
t.database_authenticatable
|
||||
t.lockable
|
||||
t.trackable
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
# Inside your Admin model
|
||||
devise :database_authenticatable, :trackable, :timeoutable, :lockable
|
||||
|
||||
# Inside your routes
|
||||
devise_for :admins
|
||||
|
||||
# Inside your protected controller
|
||||
before_filter :authenticate_admin!
|
||||
|
||||
# Inside your controllers and views
|
||||
admin_signed_in?
|
||||
current_admin
|
||||
admin_session
|
||||
|
||||
=== Configuring views
|
||||
|
||||
We built Devise to help you quickly develop an application that uses authentication. However, we don't want to be in your way when you need to customize it.
|
||||
|
||||
Since Devise is an engine, all its views are packaged inside the gem. These views will help you get started, but after sometime 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:
|
||||
|
||||
rails generate devise:views
|
||||
|
||||
Devise currently supports generating views for the following template engines (use the `-e` flag for the devise:views generator):
|
||||
|
||||
* Erb
|
||||
* Haml (http://github.com/nex3/haml)
|
||||
* Slim (http://github.com/stonean/slim)
|
||||
|
||||
Note: If you are generating Haml or Slim templates, you will need to have a few dependencies such as `ruby_parser` (for Haml), `hpricot` (for both Haml and Slim) and `haml2slim` (for Slim) installed.
|
||||
|
||||
If you have more than one role in your application (such as "User" and "Admin"), you will notice that Devise uses the same views for all roles. 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".
|
||||
|
||||
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:
|
||||
|
||||
rails generate devise:views users
|
||||
|
||||
=== 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:
|
||||
|
||||
class Admins::SessionsController < Devise::SessionsController
|
||||
end
|
||||
|
||||
2) Tell the router to use this controller:
|
||||
|
||||
devise_for :admins, :controllers => { :sessions => "admins/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".
|
||||
|
||||
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.
|
||||
|
||||
=== 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:
|
||||
|
||||
devise_for :users, :path => "usuarios", :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.
|
||||
|
||||
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:
|
||||
|
||||
devise_scope :user do
|
||||
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+ and you can also give a block to +devise_for+, resulting in the same behavior:
|
||||
|
||||
devise_for :users do
|
||||
get "sign_in", :to => "devise/sessions#new"
|
||||
end
|
||||
|
||||
Feel free to choose the one you prefer!
|
||||
|
||||
=== I18n
|
||||
|
||||
Devise uses flash messages with I18n with the flash keys :success and :failure. To customize your app, you can set up your locale file:
|
||||
|
||||
en:
|
||||
devise:
|
||||
sessions:
|
||||
signed_in: 'Signed in successfully.'
|
||||
|
||||
You can also create distinct messages based on the resource you've configured using the singular name given in routes:
|
||||
|
||||
en:
|
||||
devise:
|
||||
sessions:
|
||||
user:
|
||||
signed_in: 'Welcome user, you are signed in.'
|
||||
admin:
|
||||
signed_in: 'Hello admin!'
|
||||
|
||||
The Devise mailer uses a similar pattern to create subject messages:
|
||||
|
||||
en:
|
||||
devise:
|
||||
mailer:
|
||||
confirmation_instructions:
|
||||
subject: 'Hello everybody!'
|
||||
user_subject: 'Hello User! Please confirm your email'
|
||||
reset_password_instructions:
|
||||
subject: 'Reset instructions'
|
||||
|
||||
Take a look at our locale file to check all available messages. You may also be interested in one of the many translations that are available on our wiki:
|
||||
|
||||
http://github.com/plataformatec/devise/wiki/I18n
|
||||
|
||||
=== Test helpers
|
||||
|
||||
Devise includes some tests helpers for functional specs. To use them, you just need to include Devise::TestHelpers in your test class and use the sign_in and sign_out method. Such methods have the same signature as in controllers:
|
||||
|
||||
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)
|
||||
|
||||
You can include the Devise Test Helpers in all of your tests by adding the following to the bottom of your test/test_helper.rb file:
|
||||
|
||||
class ActionController::TestCase
|
||||
include Devise::TestHelpers
|
||||
end
|
||||
|
||||
If you're using RSpec and want the helpers automatically included within all +describe+ blocks, add a file called spec/support/devise.rb with the following contents:
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
end
|
||||
|
||||
Do not use such helpers for integration tests such as Cucumber or Webrat. Instead, fill in the form or explicitly set the user in session. For more tips, check the wiki (http://wiki.github.com/plataformatec/devise).
|
||||
|
||||
=== OAuth2
|
||||
|
||||
Devise comes with OAuth support out of the box if you're using Devise from the git repository (for now). You can read more about OAuth2 support in the wiki:
|
||||
|
||||
* http://github.com/plataformatec/devise/wiki/OAuth2:-Overview
|
||||
* http://github.com/plataformatec/devise/wiki/OAuth2:-Testing
|
||||
|
||||
=== Other ORMs
|
||||
|
||||
Devise supports ActiveRecord (default) and Mongoid. To choose other ORM, you just need to require it in the initializer file.
|
||||
|
||||
=== Migrating from other solutions
|
||||
|
||||
Devise implements encryption strategies for Clearance, Authlogic and Restful-Authentication. To make use of these strategies, you need set the desired encryptor in the encryptor initializer config option and add :encryptable to your model. You might also need to rename your encrypted password and salt columns to match Devise's fields (encrypted_password and password_salt).
|
||||
|
||||
== Additional information
|
||||
|
||||
=== Warden
|
||||
|
||||
Devise is based on Warden, which is a general Rack authentication framework created by Daniel Neighman. We encourage you to read more about Warden here:
|
||||
|
||||
http://github.com/hassox/warden
|
||||
|
||||
=== Contributors
|
||||
|
||||
We have a long list of valued contributors. Check them all at:
|
||||
|
||||
http://github.com/plataformatec/devise/contributors
|
||||
|
||||
=== Maintainers
|
||||
|
||||
* José Valim (http://github.com/josevalim)
|
||||
* Carlos Antônio da Silva (http://github.com/carlosantoniodasilva)
|
||||
|
||||
== License
|
||||
|
||||
MIT License. Copyright 2010 Plataforma Tecnologia. http://blog.plataformatec.com.br
|
||||
8
Rakefile
8
Rakefile
@@ -1,10 +1,11 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
require 'bundler/gem_tasks'
|
||||
require 'rake/testtask'
|
||||
require 'rake/rdoctask'
|
||||
require 'rdoc/task'
|
||||
|
||||
desc 'Default: run tests for all ORMs.'
|
||||
task :default => :pre_commit
|
||||
task default: :test
|
||||
|
||||
desc 'Run Devise tests for all ORMs.'
|
||||
task :pre_commit do
|
||||
@@ -22,6 +23,7 @@ Rake::TestTask.new(:test) do |t|
|
||||
t.libs << 'test'
|
||||
t.pattern = 'test/**/*_test.rb'
|
||||
t.verbose = true
|
||||
t.warning = false
|
||||
end
|
||||
|
||||
desc 'Generate documentation for Devise.'
|
||||
@@ -29,6 +31,6 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
||||
rdoc.rdoc_dir = 'rdoc'
|
||||
rdoc.title = 'Devise'
|
||||
rdoc.options << '--line-numbers' << '--inline-source'
|
||||
rdoc.rdoc_files.include('README.rdoc')
|
||||
rdoc.rdoc_files.include('README.md')
|
||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||
end
|
||||
|
||||
4
TODO
4
TODO
@@ -1,4 +0,0 @@
|
||||
* Move integration tests to Capybara
|
||||
* Better ORM integration
|
||||
* Add support to automatically refresh the access token for OAuth
|
||||
* Add test to generators using the new Rails::Generators::TestCase
|
||||
@@ -1,33 +1,51 @@
|
||||
class Devise::ConfirmationsController < ApplicationController
|
||||
include Devise::Controllers::InternalHelpers
|
||||
|
||||
class Devise::ConfirmationsController < DeviseController
|
||||
# GET /resource/confirmation/new
|
||||
def new
|
||||
build_resource({})
|
||||
render_with_scope :new
|
||||
self.resource = resource_class.new
|
||||
end
|
||||
|
||||
# POST /resource/confirmation
|
||||
def create
|
||||
self.resource = resource_class.send_confirmation_instructions(params[resource_name])
|
||||
self.resource = resource_class.send_confirmation_instructions(resource_params)
|
||||
yield resource if block_given?
|
||||
|
||||
if resource.errors.empty?
|
||||
set_flash_message :notice, :send_instructions
|
||||
redirect_to new_session_path(resource_name)
|
||||
if successfully_sent?(resource)
|
||||
respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name))
|
||||
else
|
||||
render_with_scope :new
|
||||
respond_with(resource)
|
||||
end
|
||||
end
|
||||
|
||||
# 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?
|
||||
set_flash_message :notice, :confirmed
|
||||
sign_in_and_redirect(resource_name, resource)
|
||||
set_flash_message(:notice, :confirmed) if is_flashing_format?
|
||||
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
|
||||
else
|
||||
render_with_scope :new
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# The path used after resending confirmation instructions.
|
||||
def after_resending_confirmation_instructions_path_for(resource_name)
|
||||
is_navigational_format? ? new_session_path(resource_name) : '/'
|
||||
end
|
||||
|
||||
# The path used after confirmation.
|
||||
def after_confirmation_path_for(resource_name, 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,8 +1,12 @@
|
||||
class Devise::OmniauthCallbacksController < ApplicationController
|
||||
include Devise::Controllers::InternalHelpers
|
||||
class Devise::OmniauthCallbacksController < DeviseController
|
||||
prepend_before_filter { request.env["devise.skip_timeout"] = true }
|
||||
|
||||
def passthru
|
||||
render status: 404, text: "Not found. Authentication passthru."
|
||||
end
|
||||
|
||||
def failure
|
||||
set_flash_message :alert, :failure, :kind => failed_strategy.name.to_s.humanize, :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
|
||||
|
||||
@@ -23,4 +27,8 @@ class Devise::OmniauthCallbacksController < ApplicationController
|
||||
def after_omniauth_failure_path_for(scope)
|
||||
new_session_path(scope)
|
||||
end
|
||||
|
||||
def translation_scope
|
||||
'devise.omniauth_callbacks'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,41 +1,80 @@
|
||||
class Devise::PasswordsController < ApplicationController
|
||||
class Devise::PasswordsController < DeviseController
|
||||
prepend_before_filter :require_no_authentication
|
||||
include Devise::Controllers::InternalHelpers
|
||||
# Render the #edit only if coming from a reset password email link
|
||||
append_before_filter :assert_reset_token_passed, only: :edit
|
||||
|
||||
# GET /resource/password/new
|
||||
def new
|
||||
build_resource({})
|
||||
render_with_scope :new
|
||||
self.resource = resource_class.new
|
||||
end
|
||||
|
||||
# POST /resource/password
|
||||
def create
|
||||
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
|
||||
self.resource = resource_class.send_reset_password_instructions(resource_params)
|
||||
yield resource if block_given?
|
||||
|
||||
if resource.errors.empty?
|
||||
set_flash_message :notice, :send_instructions
|
||||
redirect_to new_session_path(resource_name)
|
||||
if successfully_sent?(resource)
|
||||
respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name))
|
||||
else
|
||||
render_with_scope :new
|
||||
respond_with(resource)
|
||||
end
|
||||
end
|
||||
|
||||
# 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]
|
||||
render_with_scope :edit
|
||||
end
|
||||
|
||||
# PUT /resource/password
|
||||
def update
|
||||
self.resource = resource_class.reset_password_by_token(params[resource_name])
|
||||
self.resource = resource_class.reset_password_by_token(resource_params)
|
||||
yield resource if block_given?
|
||||
|
||||
if resource.errors.empty?
|
||||
set_flash_message :notice, :updated
|
||||
sign_in_and_redirect(resource_name, resource)
|
||||
resource.unlock_access! if unlockable?(resource)
|
||||
if Devise.sign_in_after_reset_password
|
||||
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
|
||||
set_flash_message(:notice, flash_message) if is_flashing_format?
|
||||
sign_in(resource_name, resource)
|
||||
respond_with resource, location: after_resetting_password_path_for(resource)
|
||||
else
|
||||
set_flash_message(:notice, :updated_not_active) if is_flashing_format?
|
||||
respond_with resource, location: new_session_path(resource_name)
|
||||
end
|
||||
else
|
||||
render_with_scope :edit
|
||||
respond_with resource
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
def after_resetting_password_path_for(resource)
|
||||
after_sign_in_path_for(resource)
|
||||
end
|
||||
|
||||
# The path used after sending reset password instructions
|
||||
def after_sending_reset_password_instructions_path_for(resource_name)
|
||||
new_session_path(resource_name) if is_navigational_format?
|
||||
end
|
||||
|
||||
# Check if a reset_password_token is provided in the request
|
||||
def assert_reset_token_passed
|
||||
if params[:reset_password_token].blank?
|
||||
set_flash_message(:alert, :no_token)
|
||||
redirect_to new_session_path(resource_name)
|
||||
end
|
||||
end
|
||||
|
||||
# Check if proper Lockable module methods are present & unlock strategy
|
||||
# allows to unlock resource on password reset
|
||||
def unlockable?(resource)
|
||||
resource.respond_to?(:unlock_access!) &&
|
||||
resource.respond_to?(:unlock_strategy_enabled?) &&
|
||||
resource.unlock_strategy_enabled?(:email)
|
||||
end
|
||||
|
||||
def translation_scope
|
||||
'devise.passwords'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,55 +1,73 @@
|
||||
class Devise::RegistrationsController < ApplicationController
|
||||
prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ]
|
||||
prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]
|
||||
include Devise::Controllers::InternalHelpers
|
||||
class Devise::RegistrationsController < DeviseController
|
||||
prepend_before_filter :require_no_authentication, only: [:new, :create, :cancel]
|
||||
prepend_before_filter :authenticate_scope!, only: [:edit, :update, :destroy]
|
||||
|
||||
# GET /resource/sign_up
|
||||
def new
|
||||
build_resource({})
|
||||
render_with_scope :new
|
||||
set_minimum_password_length
|
||||
yield resource if block_given?
|
||||
respond_with self.resource
|
||||
end
|
||||
|
||||
# POST /resource
|
||||
def create
|
||||
build_resource
|
||||
build_resource(sign_up_params)
|
||||
|
||||
if resource.save
|
||||
if resource.active?
|
||||
set_flash_message :notice, :signed_up
|
||||
sign_in_and_redirect(resource_name, resource)
|
||||
resource.save
|
||||
yield resource if block_given?
|
||||
if resource.persisted?
|
||||
if resource.active_for_authentication?
|
||||
set_flash_message :notice, :signed_up if is_flashing_format?
|
||||
sign_up(resource_name, resource)
|
||||
respond_with resource, location: after_sign_up_path_for(resource)
|
||||
else
|
||||
set_flash_message :notice, :inactive_signed_up, :reason => resource.inactive_message.to_s
|
||||
expire_session_data_after_sign_in!
|
||||
redirect_to after_inactive_sign_up_path_for(resource)
|
||||
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
|
||||
expire_data_after_sign_in!
|
||||
respond_with resource, location: after_inactive_sign_up_path_for(resource)
|
||||
end
|
||||
else
|
||||
clean_up_passwords(resource)
|
||||
render_with_scope :new
|
||||
clean_up_passwords resource
|
||||
set_minimum_password_length
|
||||
respond_with resource
|
||||
end
|
||||
end
|
||||
|
||||
# GET /resource/edit
|
||||
def edit
|
||||
render_with_scope :edit
|
||||
render :edit
|
||||
end
|
||||
|
||||
# PUT /resource
|
||||
# We need to use a copy of the resource because we don't want to change
|
||||
# the current user in place.
|
||||
def update
|
||||
if resource.update_with_password(params[resource_name])
|
||||
set_flash_message :notice, :updated
|
||||
sign_in resource_name, resource, :bypass => true
|
||||
redirect_to after_update_path_for(resource)
|
||||
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)
|
||||
|
||||
resource_updated = update_resource(resource, account_update_params)
|
||||
yield resource if block_given?
|
||||
if resource_updated
|
||||
if is_flashing_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)
|
||||
else
|
||||
clean_up_passwords(resource)
|
||||
render_with_scope :edit
|
||||
clean_up_passwords resource
|
||||
respond_with resource
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /resource
|
||||
def destroy
|
||||
resource.destroy
|
||||
sign_out_and_redirect(self.resource)
|
||||
set_flash_message :notice, :destroyed
|
||||
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
|
||||
set_flash_message :notice, :destroyed if is_flashing_format?
|
||||
yield resource if block_given?
|
||||
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
|
||||
end
|
||||
|
||||
# GET /resource/cancel
|
||||
@@ -58,53 +76,72 @@ class Devise::RegistrationsController < ApplicationController
|
||||
# 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
|
||||
|
||||
protected
|
||||
|
||||
# Build a devise resource passing in the session. Useful to move
|
||||
# temporary session data to the newly created user.
|
||||
def build_resource(hash=nil)
|
||||
hash ||= params[resource_name] || {}
|
||||
self.resource = resource_class.new_with_session(hash, session)
|
||||
end
|
||||
def update_needs_confirmation?(resource, previous)
|
||||
resource.respond_to?(:pending_reconfirmation?) &&
|
||||
resource.pending_reconfirmation? &&
|
||||
previous != resource.unconfirmed_email
|
||||
end
|
||||
|
||||
# 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)
|
||||
end
|
||||
# By default we want to require a password checks on update.
|
||||
# You can overwrite this method in your own RegistrationsController.
|
||||
def update_resource(resource, params)
|
||||
resource.update_with_password(params)
|
||||
end
|
||||
|
||||
# Overwrite redirect_for_sign_in so it takes uses after_sign_up_path_for.
|
||||
def redirect_location(scope, resource) #:nodoc:
|
||||
stored_location_for(scope) || after_sign_up_path_for(resource)
|
||||
end
|
||||
# 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)
|
||||
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)
|
||||
root_path
|
||||
end
|
||||
# Signs in a user on sign up. You can overwrite this method in your own
|
||||
# RegistrationsController.
|
||||
def sign_up(resource_name, resource)
|
||||
sign_in(resource_name, resource)
|
||||
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)
|
||||
if defined?(super)
|
||||
ActiveSupport::Deprecation.warn "Defining after_update_path_for in ApplicationController " <<
|
||||
"is deprecated. Please add a RegistrationsController to your application and define it there."
|
||||
super
|
||||
else
|
||||
after_sign_in_path_for(resource)
|
||||
end
|
||||
end
|
||||
# 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)
|
||||
end
|
||||
|
||||
# Authenticates the current scope and gets a copy of the current resource.
|
||||
# We need to use a copy because we don't want actions like update changing
|
||||
# the current user in place.
|
||||
def authenticate_scope!
|
||||
send(:"authenticate_#{resource_name}!", true)
|
||||
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
|
||||
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)
|
||||
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)
|
||||
end
|
||||
|
||||
# Authenticates the current scope and gets the current resource from the session.
|
||||
def authenticate_scope!
|
||||
send(:"authenticate_#{resource_name}!", force: true)
|
||||
self.resource = send(:"current_#{resource_name}")
|
||||
end
|
||||
|
||||
def sign_up_params
|
||||
devise_parameter_sanitizer.sanitize(:sign_up)
|
||||
end
|
||||
|
||||
def account_update_params
|
||||
devise_parameter_sanitizer.sanitize(:account_update)
|
||||
end
|
||||
|
||||
def translation_scope
|
||||
'devise.registrations'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,25 +1,81 @@
|
||||
class Devise::SessionsController < ApplicationController
|
||||
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
|
||||
include Devise::Controllers::InternalHelpers
|
||||
class Devise::SessionsController < DeviseController
|
||||
prepend_before_filter :require_no_authentication, only: [:new, :create]
|
||||
prepend_before_filter :allow_params_authentication!, only: :create
|
||||
prepend_before_filter :verify_signed_out_user, only: :destroy
|
||||
prepend_before_filter only: [:create, :destroy] { request.env["devise.skip_timeout"] = true }
|
||||
|
||||
# GET /resource/sign_in
|
||||
def new
|
||||
clean_up_passwords(build_resource)
|
||||
render_with_scope :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
|
||||
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
|
||||
set_flash_message(:notice, :signed_in) if is_navigational_format?
|
||||
self.resource = warden.authenticate!(auth_options)
|
||||
set_flash_message(:notice, :signed_in) if is_flashing_format?
|
||||
sign_in(resource_name, resource)
|
||||
respond_with resource, :location => redirect_location(resource_name, resource)
|
||||
yield resource if block_given?
|
||||
respond_with resource, location: after_sign_in_path_for(resource)
|
||||
end
|
||||
|
||||
# GET /resource/sign_out
|
||||
# DELETE /resource/sign_out
|
||||
def destroy
|
||||
signed_in = signed_in?(resource_name)
|
||||
sign_out_and_redirect(resource_name)
|
||||
set_flash_message :notice, :signed_out if signed_in
|
||||
signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
|
||||
set_flash_message :notice, :signed_out if signed_out && is_flashing_format?
|
||||
yield if block_given?
|
||||
respond_to_on_destroy
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def sign_in_params
|
||||
devise_parameter_sanitizer.sanitize(:sign_in)
|
||||
end
|
||||
|
||||
def serialize_options(resource)
|
||||
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] }
|
||||
end
|
||||
|
||||
def auth_options
|
||||
{ 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 if is_flashing_format?
|
||||
|
||||
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,34 +1,49 @@
|
||||
class Devise::UnlocksController < ApplicationController
|
||||
class Devise::UnlocksController < DeviseController
|
||||
prepend_before_filter :require_no_authentication
|
||||
include Devise::Controllers::InternalHelpers
|
||||
|
||||
# GET /resource/unlock/new
|
||||
def new
|
||||
build_resource({})
|
||||
render_with_scope :new
|
||||
self.resource = resource_class.new
|
||||
end
|
||||
|
||||
# POST /resource/unlock
|
||||
def create
|
||||
self.resource = resource_class.send_unlock_instructions(params[resource_name])
|
||||
self.resource = resource_class.send_unlock_instructions(resource_params)
|
||||
yield resource if block_given?
|
||||
|
||||
if resource.errors.empty?
|
||||
set_flash_message :notice, :send_instructions
|
||||
redirect_to new_session_path(resource_name)
|
||||
if successfully_sent?(resource)
|
||||
respond_with({}, location: after_sending_unlock_instructions_path_for(resource))
|
||||
else
|
||||
render_with_scope :new
|
||||
respond_with(resource)
|
||||
end
|
||||
end
|
||||
|
||||
# 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
|
||||
sign_in_and_redirect(resource_name, resource)
|
||||
set_flash_message :notice, :unlocked if is_flashing_format?
|
||||
respond_with_navigational(resource){ redirect_to after_unlock_path_for(resource) }
|
||||
else
|
||||
render_with_scope :new
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# The path used after sending unlock password instructions
|
||||
def after_sending_unlock_instructions_path_for(resource)
|
||||
new_session_path(resource) if is_navigational_format?
|
||||
end
|
||||
|
||||
# The path used after unlocking the resource
|
||||
def after_unlock_path_for(resource)
|
||||
new_session_path(resource) if is_navigational_format?
|
||||
end
|
||||
|
||||
def translation_scope
|
||||
'devise.unlocks'
|
||||
end
|
||||
end
|
||||
|
||||
198
app/controllers/devise_controller.rb
Normal file
198
app/controllers/devise_controller.rb
Normal file
@@ -0,0 +1,198 @@
|
||||
# All Devise controllers are inherited from here.
|
||||
class DeviseController < Devise.parent_controller.constantize
|
||||
include Devise::Controllers::ScopedViews
|
||||
|
||||
helper DeviseHelper
|
||||
|
||||
helpers = %w(resource scope_name resource_name signed_in_resource
|
||||
resource_class resource_params devise_mapping)
|
||||
helper_method(*helpers)
|
||||
|
||||
prepend_before_filter :assert_is_devise_resource!
|
||||
respond_to :html if mimes_for_respond_to.empty?
|
||||
|
||||
protected
|
||||
|
||||
# Gets the actual resource stored in the instance variable
|
||||
def resource
|
||||
instance_variable_get(:"@#{resource_name}")
|
||||
end
|
||||
|
||||
# Proxy to devise map name
|
||||
def resource_name
|
||||
devise_mapping.name
|
||||
end
|
||||
alias :scope_name :resource_name
|
||||
|
||||
# Proxy to devise map class
|
||||
def resource_class
|
||||
devise_mapping.to
|
||||
end
|
||||
|
||||
# Returns a signed in resource from session (if one exists)
|
||||
def signed_in_resource
|
||||
warden.authenticate(scope: resource_name)
|
||||
end
|
||||
|
||||
# Attempt to find the mapped route for devise based on request path
|
||||
def devise_mapping
|
||||
@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
|
||||
["#{devise_mapping.scoped_path}/#{controller_name}"] + super
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Checks whether it's a devise mapped resource or not.
|
||||
def assert_is_devise_resource! #:nodoc:
|
||||
unknown_action! <<-MESSAGE unless devise_mapping
|
||||
Could not find devise mapping for path #{request.fullpath.inspect}.
|
||||
This may happen for two reasons:
|
||||
|
||||
1) You forgot to wrap your route inside the scope block. For example:
|
||||
|
||||
devise_scope :user do
|
||||
get "/some/route" => "some_devise_controller"
|
||||
end
|
||||
|
||||
2) You are testing a Devise controller bypassing the router.
|
||||
If so, you can explicitly tell Devise which mapping to use:
|
||||
|
||||
@request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
|
||||
MESSAGE
|
||||
end
|
||||
|
||||
# Returns real navigational formats which are supported by Rails
|
||||
def navigational_formats
|
||||
@navigational_formats ||= Devise.navigational_formats.select { |format| Mime::EXTENSION_LOOKUP[format.to_s] }
|
||||
end
|
||||
|
||||
def unknown_action!(msg)
|
||||
logger.debug "[Devise] #{msg}" if logger
|
||||
raise AbstractController::ActionNotFound, msg
|
||||
end
|
||||
|
||||
# Sets the resource creating an instance variable
|
||||
def resource=(new_resource)
|
||||
instance_variable_set(:"@#{resource_name}", new_resource)
|
||||
end
|
||||
|
||||
# Helper for use in before_filters where no authentication is required.
|
||||
#
|
||||
# Example:
|
||||
# before_filter :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
|
||||
warden.authenticate?(*args)
|
||||
else
|
||||
warden.authenticated?(resource_name)
|
||||
end
|
||||
|
||||
if authenticated && resource = warden.user(resource_name)
|
||||
flash[:alert] = I18n.t("devise.failure.already_authenticated")
|
||||
redirect_to after_sign_in_path_for(resource)
|
||||
end
|
||||
end
|
||||
|
||||
# Helper for use after calling send_*_instructions methods on a resource.
|
||||
# If we are in paranoid mode, we always act as if the resource was valid
|
||||
# and instructions were sent.
|
||||
def successfully_sent?(resource)
|
||||
notice = if Devise.paranoid
|
||||
resource.errors.clear
|
||||
:send_paranoid_instructions
|
||||
elsif resource.errors.empty?
|
||||
:send_instructions
|
||||
end
|
||||
|
||||
if notice
|
||||
set_flash_message :notice, notice if is_flashing_format?
|
||||
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 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:
|
||||
# devise:
|
||||
# passwords:
|
||||
# #default_scope_messages - only if resource_scope is not found
|
||||
# user:
|
||||
# #resource_scope_messages
|
||||
#
|
||||
# Please refer to README or en.yml locale file to check what messages are
|
||||
# available.
|
||||
def set_flash_message(key, kind, options = {})
|
||||
message = find_message(kind, options)
|
||||
if options[:now]
|
||||
flash.now[key] = message if message.present?
|
||||
else
|
||||
flash[key] = message if message.present?
|
||||
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] ||= translation_scope
|
||||
options[:default] = Array(options[:default]).unshift(kind.to_sym)
|
||||
options[:resource_name] = resource_name
|
||||
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
|
||||
|
||||
def respond_with_navigational(*args, &block)
|
||||
respond_with(*args) do |format|
|
||||
format.any(*navigational_formats, &block)
|
||||
end
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.fetch(resource_name, {})
|
||||
end
|
||||
|
||||
ActiveSupport.run_load_hooks(:devise_controller, self)
|
||||
end
|
||||
@@ -10,8 +10,8 @@ module DeviseHelper
|
||||
|
||||
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_name)
|
||||
count: resource.errors.count,
|
||||
resource: resource.class.model_name.human.downcase)
|
||||
|
||||
html = <<-HTML
|
||||
<div id="error_explanation">
|
||||
|
||||
@@ -1,88 +1,20 @@
|
||||
class Devise::Mailer < ::ActionMailer::Base
|
||||
include Devise::Controllers::ScopedViews
|
||||
attr_reader :scope_name, :resource
|
||||
if defined?(ActionMailer)
|
||||
class Devise::Mailer < Devise.parent_mailer.constantize
|
||||
include Devise::Mailers::Helpers
|
||||
|
||||
def confirmation_instructions(record)
|
||||
setup_mail(record, :confirmation_instructions)
|
||||
end
|
||||
|
||||
def reset_password_instructions(record)
|
||||
setup_mail(record, :reset_password_instructions)
|
||||
end
|
||||
|
||||
def unlock_instructions(record)
|
||||
setup_mail(record, :unlock_instructions)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Configure default email options
|
||||
def setup_mail(record, action)
|
||||
initialize_from_record(record)
|
||||
mail headers_for(action)
|
||||
end
|
||||
|
||||
def initialize_from_record(record)
|
||||
@scope_name = Devise::Mapping.find_scope!(record)
|
||||
@resource = instance_variable_set("@#{devise_mapping.name}", record)
|
||||
end
|
||||
|
||||
def devise_mapping
|
||||
@devise_mapping ||= Devise.mappings[scope_name]
|
||||
end
|
||||
|
||||
def headers_for(action)
|
||||
headers = {
|
||||
:subject => translate(devise_mapping, action),
|
||||
:from => mailer_sender(devise_mapping),
|
||||
:to => resource.email,
|
||||
:template_path => template_paths
|
||||
}
|
||||
|
||||
if resource.respond_to?(:headers_for)
|
||||
headers.merge!(resource.headers_for(action))
|
||||
def confirmation_instructions(record, token, opts={})
|
||||
@token = token
|
||||
devise_mail(record, :confirmation_instructions, opts)
|
||||
end
|
||||
|
||||
unless headers.key?(:reply_to)
|
||||
headers[:reply_to] = headers[:from]
|
||||
def reset_password_instructions(record, token, opts={})
|
||||
@token = token
|
||||
devise_mail(record, :reset_password_instructions, opts)
|
||||
end
|
||||
|
||||
headers
|
||||
end
|
||||
|
||||
def mailer_sender(mapping)
|
||||
if Devise.mailer_sender.is_a?(Proc)
|
||||
Devise.mailer_sender.call(mapping.name)
|
||||
else
|
||||
Devise.mailer_sender
|
||||
def unlock_instructions(record, token, opts={})
|
||||
@token = token
|
||||
devise_mail(record, :unlock_instructions, opts)
|
||||
end
|
||||
end
|
||||
|
||||
def template_paths
|
||||
template_path = [self.class.mailer_name]
|
||||
template_path.unshift "#{@devise_mapping.scoped_path}/mailer" if self.class.scoped_views?
|
||||
template_path
|
||||
end
|
||||
|
||||
# Setup a subject doing an I18n lookup. At first, it attemps to set a subject
|
||||
# based on the current mapping:
|
||||
#
|
||||
# en:
|
||||
# devise:
|
||||
# mailer:
|
||||
# confirmation_instructions:
|
||||
# user_subject: '...'
|
||||
#
|
||||
# If one does not exist, it fallbacks to ActionMailer default:
|
||||
#
|
||||
# en:
|
||||
# devise:
|
||||
# mailer:
|
||||
# confirmation_instructions:
|
||||
# subject: '...'
|
||||
#
|
||||
def translate(mapping, key)
|
||||
I18n.t(:"#{mapping.name}_subject", :scope => [:devise, :mailer, key],
|
||||
:default => [:subject, key.to_s.humanize])
|
||||
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| %>
|
||||
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<p><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></p>
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
|
||||
</div>
|
||||
|
||||
<p><%= f.submit "Resend confirmation instructions" %></p>
|
||||
<div class="actions">
|
||||
<%= f.submit "Resend confirmation instructions" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "devise/shared/links" %>
|
||||
<%= render "devise/shared/links" %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<p>Welcome <%= @resource.email %>!</p>
|
||||
<p>Welcome <%= @email %>!</p>
|
||||
|
||||
<p>You can confirm your account through the link below:</p>
|
||||
<p>You can confirm your account email through the link below:</p>
|
||||
|
||||
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
|
||||
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<p>Hello <%= @resource.email %>!</p>
|
||||
|
||||
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
|
||||
<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 => @resource.reset_password_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>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<p>Hello <%= @resource.email %>!</p>
|
||||
|
||||
<p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
|
||||
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
|
||||
|
||||
<p>Click the link below to unlock your account:</p>
|
||||
|
||||
<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_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| %>
|
||||
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= f.hidden_field :reset_password_token %>
|
||||
|
||||
<p><%= f.label :password, "New password" %><br />
|
||||
<%= f.password_field :password %></p>
|
||||
<div class="field">
|
||||
<%= f.label :password, "New password" %><br />
|
||||
<% if @minimum_password_length %>
|
||||
<em>(<%= @minimum_password_length %> characters minimum)</em>
|
||||
<% end %><br />
|
||||
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<p><%= f.label :password_confirmation, "Confirm new password" %><br />
|
||||
<%= f.password_field :password_confirmation %></p>
|
||||
<div class="field">
|
||||
<%= f.label :password_confirmation, "Confirm new password" %><br />
|
||||
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<p><%= f.submit "Change my password" %></p>
|
||||
<div class="actions">
|
||||
<%= f.submit "Change my password" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "devise/shared/links" %>
|
||||
<%= 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| %>
|
||||
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<p><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></p>
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true %>
|
||||
</div>
|
||||
|
||||
<p><%= f.submit "Send me reset password instructions" %></p>
|
||||
<div class="actions">
|
||||
<%= f.submit "Send me reset password instructions" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "devise/shared/links" %>
|
||||
<%= render "devise/shared/links" %>
|
||||
|
||||
@@ -1,25 +1,39 @@
|
||||
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
|
||||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<p><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></p>
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true %>
|
||||
</div>
|
||||
|
||||
<p><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
|
||||
<%= f.password_field :password %></p>
|
||||
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
|
||||
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
|
||||
<% end %>
|
||||
|
||||
<p><%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation %></p>
|
||||
<div class="field">
|
||||
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
|
||||
<%= f.password_field :password, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<p><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
|
||||
<%= f.password_field :current_password %></p>
|
||||
<div class="field">
|
||||
<%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<p><%= f.submit "Update" %></p>
|
||||
<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: "off" %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit "Update" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<h3>Cancel my account</h3>
|
||||
|
||||
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :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| %>
|
||||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<p><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></p>
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true %>
|
||||
</div>
|
||||
|
||||
<p><%= f.label :password %><br />
|
||||
<%= f.password_field :password %></p>
|
||||
<div class="field">
|
||||
<%= f.label :password %>
|
||||
<% if @minimum_password_length %>
|
||||
<em>(<%= @minimum_password_length %> characters minimum)</em>
|
||||
<% end %><br />
|
||||
<%= f.password_field :password, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<p><%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation %></p>
|
||||
<div class="field">
|
||||
<%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<p><%= f.submit "Sign up" %></p>
|
||||
<div class="actions">
|
||||
<%= f.submit "Sign up" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "devise/shared/links" %>
|
||||
<%= 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| %>
|
||||
<p><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></p>
|
||||
<%= 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 %>
|
||||
</div>
|
||||
|
||||
<p><%= f.label :password %><br />
|
||||
<%= f.password_field :password %></p>
|
||||
<div class="field">
|
||||
<%= f.label :password %><br />
|
||||
<%= f.password_field :password, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<% if devise_mapping.rememberable? -%>
|
||||
<p><%= f.check_box :remember_me %> <%= f.label :remember_me %></p>
|
||||
<div class="field">
|
||||
<%= f.check_box :remember_me %>
|
||||
<%= f.label :remember_me %>
|
||||
</div>
|
||||
<% end -%>
|
||||
|
||||
<p><%= f.submit "Sign in" %></p>
|
||||
<div class="actions">
|
||||
<%= f.submit "Log in" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "devise/shared/links" %>
|
||||
<%= render "devise/shared/links" %>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<%- if controller_name != 'sessions' %>
|
||||
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
||||
<%= 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 -%>
|
||||
|
||||
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
|
||||
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
|
||||
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
@@ -22,4 +22,4 @@
|
||||
<%- 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 -%>
|
||||
<% 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| %>
|
||||
<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<p><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></p>
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true %>
|
||||
</div>
|
||||
|
||||
<p><%= f.submit "Resend unlock instructions" %></p>
|
||||
<div class="actions">
|
||||
<%= f.submit "Resend unlock instructions" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => "devise/shared/links" %>
|
||||
<%= render "devise/shared/links" %>
|
||||
|
||||
@@ -1,48 +1,60 @@
|
||||
# Additional translations at http://github.com/plataformatec/devise/wiki/I18n
|
||||
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
|
||||
|
||||
en:
|
||||
devise:
|
||||
confirmations:
|
||||
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 %{authentication_keys} or password."
|
||||
locked: "Your account is locked."
|
||||
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 email address before continuing."
|
||||
mailer:
|
||||
confirmation_instructions:
|
||||
subject: "Confirmation instructions"
|
||||
reset_password_instructions:
|
||||
subject: "Reset password instructions"
|
||||
unlock_instructions:
|
||||
subject: "Unlock instructions"
|
||||
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 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 has been changed successfully. You are now signed in."
|
||||
updated_not_active: "Your password has been changed successfully."
|
||||
registrations:
|
||||
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 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."
|
||||
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 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:
|
||||
not_found: "not found"
|
||||
already_confirmed: "was already confirmed, please try signing in"
|
||||
confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
|
||||
expired: "has expired, please request a new one"
|
||||
not_found: "not found"
|
||||
not_locked: "was not locked"
|
||||
not_saved:
|
||||
one: "1 error prohibited this %{resource} from being saved:"
|
||||
other: "%{count} errors prohibited this %{resource} from being saved:"
|
||||
|
||||
devise:
|
||||
failure:
|
||||
unauthenticated: 'You need to sign in or sign up before continuing.'
|
||||
unconfirmed: 'You have to confirm your account before continuing.'
|
||||
locked: 'Your account is locked.'
|
||||
invalid: 'Invalid email or password.'
|
||||
invalid_token: 'Invalid authentication token.'
|
||||
timeout: 'Your session expired, please sign in again to continue.'
|
||||
inactive: 'Your account was not activated yet.'
|
||||
sessions:
|
||||
signed_in: 'Signed in successfully.'
|
||||
signed_out: 'Signed out successfully.'
|
||||
passwords:
|
||||
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
|
||||
updated: 'Your password was changed successfully. You are now signed in.'
|
||||
confirmations:
|
||||
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
|
||||
confirmed: 'Your account was successfully confirmed. You are now signed in.'
|
||||
registrations:
|
||||
signed_up: 'Welcome! You have signed up successfully.'
|
||||
inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
|
||||
updated: 'You updated your account successfully.'
|
||||
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
|
||||
unlocks:
|
||||
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
|
||||
unlocked: 'Your account was successfully unlocked. You are now signed in.'
|
||||
omniauth_callbacks:
|
||||
success: 'Successfully authorized from %{kind} account.'
|
||||
failure: 'Could not authorize you from %{kind} because "%{reason}".'
|
||||
mailer:
|
||||
confirmation_instructions:
|
||||
subject: 'Confirmation instructions'
|
||||
reset_password_instructions:
|
||||
subject: 'Reset password instructions'
|
||||
unlock_instructions:
|
||||
subject: 'Unlock Instructions'
|
||||
|
||||
@@ -5,21 +5,25 @@ require "devise/version"
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "devise"
|
||||
s.version = Devise::VERSION.dup
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.platform = Gem::Platform::RUBY
|
||||
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,spec,features}/*`.split("\n")
|
||||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
||||
s.test_files = `git ls-files -- test/*`.split("\n")
|
||||
s.require_paths = ["lib"]
|
||||
s.required_ruby_version = '>= 1.9.3'
|
||||
|
||||
s.add_dependency("warden", "~> 1.0.3")
|
||||
s.add_dependency("orm_adapter", "~> 0.0.3")
|
||||
s.add_dependency("bcrypt-ruby", "~> 2.1.2")
|
||||
end
|
||||
s.add_dependency("warden", "~> 1.2.3")
|
||||
s.add_dependency("orm_adapter", "~> 0.1")
|
||||
s.add_dependency("bcrypt", "~> 3.0")
|
||||
s.add_dependency("thread_safe", "~> 0.1")
|
||||
s.add_dependency("railties", ">= 3.2.6", "< 5")
|
||||
s.add_dependency("responders")
|
||||
end
|
||||
|
||||
BIN
devise.png
Normal file
BIN
devise.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
29
gemfiles/Gemfile.rails-3.2-stable
Normal file
29
gemfiles/Gemfile.rails-3.2-stable
Normal file
@@ -0,0 +1,29 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: '..'
|
||||
|
||||
gem "rails", github: 'rails/rails', branch: '3-2-stable'
|
||||
gem "omniauth", "~> 1.2.0"
|
||||
gem "omniauth-oauth2", "~> 1.1.0"
|
||||
gem "rdoc"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.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
|
||||
|
||||
group :mongoid do
|
||||
gem "mongoid", "~> 3.0"
|
||||
end
|
||||
169
gemfiles/Gemfile.rails-3.2-stable.lock
Normal file
169
gemfiles/Gemfile.rails-3.2-stable.lock
Normal file
@@ -0,0 +1,169 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/rails.git
|
||||
revision: b344986bc3d94ca7821fc5e0eef1874882ac6cbb
|
||||
branch: 3-2-stable
|
||||
specs:
|
||||
actionmailer (3.2.21)
|
||||
actionpack (= 3.2.21)
|
||||
mail (~> 2.5.4)
|
||||
actionpack (3.2.21)
|
||||
activemodel (= 3.2.21)
|
||||
activesupport (= 3.2.21)
|
||||
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.21)
|
||||
activesupport (= 3.2.21)
|
||||
builder (~> 3.0.0)
|
||||
activerecord (3.2.21)
|
||||
activemodel (= 3.2.21)
|
||||
activesupport (= 3.2.21)
|
||||
arel (~> 3.0.2)
|
||||
tzinfo (~> 0.3.29)
|
||||
activeresource (3.2.21)
|
||||
activemodel (= 3.2.21)
|
||||
activesupport (= 3.2.21)
|
||||
activesupport (3.2.21)
|
||||
i18n (~> 0.6, >= 0.6.4)
|
||||
multi_json (~> 1.0)
|
||||
rails (3.2.21)
|
||||
actionmailer (= 3.2.21)
|
||||
actionpack (= 3.2.21)
|
||||
activerecord (= 3.2.21)
|
||||
activeresource (= 3.2.21)
|
||||
activesupport (= 3.2.21)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.2.21)
|
||||
railties (3.2.21)
|
||||
actionpack (= 3.2.21)
|
||||
activesupport (= 3.2.21)
|
||||
rack-ssl (~> 1.3.2)
|
||||
rake (>= 0.8.7)
|
||||
rdoc (~> 3.4)
|
||||
thor (>= 0.14.6, < 2.0)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (3.4.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 3.2.6, < 5)
|
||||
responders
|
||||
thread_safe (~> 0.1)
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
arel (3.0.3)
|
||||
bcrypt (3.1.10)
|
||||
builder (3.0.4)
|
||||
erubis (2.7.0)
|
||||
faraday (0.9.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
hashie (3.4.0)
|
||||
hike (1.2.3)
|
||||
i18n (0.7.0)
|
||||
journey (1.0.4)
|
||||
json (1.8.2)
|
||||
jwt (1.4.1)
|
||||
mail (2.5.4)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
metaclass (0.0.4)
|
||||
mime-types (1.25.1)
|
||||
mini_portile (0.6.2)
|
||||
mocha (1.1.0)
|
||||
metaclass (~> 0.0.1)
|
||||
mongoid (3.1.6)
|
||||
activemodel (~> 3.2)
|
||||
moped (~> 1.4)
|
||||
origin (~> 1.0)
|
||||
tzinfo (~> 0.3.29)
|
||||
moped (1.5.2)
|
||||
multi_json (1.11.0)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.6.6.2)
|
||||
mini_portile (~> 0.6.0)
|
||||
oauth2 (0.9.4)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
jwt (~> 1.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (~> 1.2)
|
||||
omniauth (1.2.2)
|
||||
hashie (>= 1.2, < 4)
|
||||
rack (~> 1.0)
|
||||
omniauth-facebook (1.6.0)
|
||||
omniauth-oauth2 (~> 1.1)
|
||||
omniauth-oauth2 (1.1.2)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
multi_json (~> 1.3)
|
||||
oauth2 (~> 0.9.3)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
origin (1.1.0)
|
||||
orm_adapter (0.5.0)
|
||||
polyglot (0.3.5)
|
||||
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.4)
|
||||
rack
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rake (10.4.2)
|
||||
rdoc (3.12.2)
|
||||
json (~> 1.4)
|
||||
responders (1.1.2)
|
||||
railties (>= 3.2, < 4.2)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (2.2.3)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
sqlite3 (1.3.10)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tilt (1.4.1)
|
||||
treetop (1.4.15)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.43)
|
||||
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 (~> 1.1)
|
||||
mongoid (~> 3.0)
|
||||
omniauth (~> 1.2.0)
|
||||
omniauth-facebook
|
||||
omniauth-oauth2 (~> 1.1.0)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
rails!
|
||||
rdoc
|
||||
sqlite3
|
||||
webrat (= 0.7.3)
|
||||
29
gemfiles/Gemfile.rails-4.0-stable
Normal file
29
gemfiles/Gemfile.rails-4.0-stable
Normal file
@@ -0,0 +1,29 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: '..'
|
||||
|
||||
gem "rails", github: 'rails/rails', branch: '4-0-stable'
|
||||
gem "omniauth", "~> 1.2.0"
|
||||
gem "omniauth-oauth2", "~> 1.1.0"
|
||||
gem "rdoc"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.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
|
||||
|
||||
group :mongoid do
|
||||
gem "mongoid", "~> 4.0.0"
|
||||
end
|
||||
163
gemfiles/Gemfile.rails-4.0-stable.lock
Normal file
163
gemfiles/Gemfile.rails-4.0-stable.lock
Normal file
@@ -0,0 +1,163 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/rails.git
|
||||
revision: 7ec9c9635bf4d57009135ed11e89d8bf32306d73
|
||||
branch: 4-0-stable
|
||||
specs:
|
||||
actionmailer (4.0.13)
|
||||
actionpack (= 4.0.13)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
actionpack (4.0.13)
|
||||
activesupport (= 4.0.13)
|
||||
builder (~> 3.1.0)
|
||||
erubis (~> 2.7.0)
|
||||
rack (~> 1.5.2)
|
||||
rack-test (~> 0.6.2)
|
||||
activemodel (4.0.13)
|
||||
activesupport (= 4.0.13)
|
||||
builder (~> 3.1.0)
|
||||
activerecord (4.0.13)
|
||||
activemodel (= 4.0.13)
|
||||
activerecord-deprecated_finders (~> 1.0.2)
|
||||
activesupport (= 4.0.13)
|
||||
arel (~> 4.0.0)
|
||||
activesupport (4.0.13)
|
||||
i18n (~> 0.6, >= 0.6.9)
|
||||
minitest (~> 4.2)
|
||||
multi_json (~> 1.3)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo (~> 0.3.37)
|
||||
rails (4.0.13)
|
||||
actionmailer (= 4.0.13)
|
||||
actionpack (= 4.0.13)
|
||||
activerecord (= 4.0.13)
|
||||
activesupport (= 4.0.13)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.0.13)
|
||||
sprockets-rails (~> 2.0)
|
||||
railties (4.0.13)
|
||||
actionpack (= 4.0.13)
|
||||
activesupport (= 4.0.13)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (3.4.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 3.2.6, < 5)
|
||||
responders
|
||||
thread_safe (~> 0.1)
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
activerecord-deprecated_finders (1.0.3)
|
||||
arel (4.0.2)
|
||||
bcrypt (3.1.10)
|
||||
bson (2.3.0)
|
||||
builder (3.1.4)
|
||||
connection_pool (2.1.3)
|
||||
erubis (2.7.0)
|
||||
faraday (0.9.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
hashie (3.4.0)
|
||||
hike (1.2.3)
|
||||
i18n (0.7.0)
|
||||
jwt (1.4.1)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
metaclass (0.0.4)
|
||||
mime-types (2.4.3)
|
||||
mini_portile (0.6.2)
|
||||
minitest (4.7.5)
|
||||
mocha (1.1.0)
|
||||
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.4)
|
||||
bson (~> 2.2)
|
||||
connection_pool (~> 2.0)
|
||||
optionable (~> 0.2.0)
|
||||
multi_json (1.11.0)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.6.6.2)
|
||||
mini_portile (~> 0.6.0)
|
||||
oauth2 (0.9.4)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
jwt (~> 1.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (~> 1.2)
|
||||
omniauth (1.2.2)
|
||||
hashie (>= 1.2, < 4)
|
||||
rack (~> 1.0)
|
||||
omniauth-facebook (1.6.0)
|
||||
omniauth-oauth2 (~> 1.1)
|
||||
omniauth-oauth2 (1.1.2)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
multi_json (~> 1.3)
|
||||
oauth2 (~> 0.9.3)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
optionable (0.2.0)
|
||||
origin (2.1.1)
|
||||
orm_adapter (0.5.0)
|
||||
rack (1.5.2)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rake (10.4.2)
|
||||
rdoc (4.2.0)
|
||||
responders (1.1.2)
|
||||
railties (>= 3.2, < 4.2)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (2.12.3)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
sprockets-rails (2.2.4)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sqlite3 (1.3.10)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tilt (1.4.1)
|
||||
tzinfo (0.3.43)
|
||||
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 (~> 1.1)
|
||||
mongoid (~> 4.0.0)
|
||||
omniauth (~> 1.2.0)
|
||||
omniauth-facebook
|
||||
omniauth-oauth2 (~> 1.1.0)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
rails!
|
||||
rdoc
|
||||
sqlite3
|
||||
webrat (= 0.7.3)
|
||||
29
gemfiles/Gemfile.rails-4.1-stable
Normal file
29
gemfiles/Gemfile.rails-4.1-stable
Normal file
@@ -0,0 +1,29 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: '..'
|
||||
|
||||
gem "rails", github: 'rails/rails', branch: '4-1-stable'
|
||||
gem "omniauth", "~> 1.2.0"
|
||||
gem "omniauth-oauth2", "~> 1.1.0"
|
||||
gem "rdoc"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.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
|
||||
|
||||
group :mongoid do
|
||||
gem "mongoid", "~> 4.0.0"
|
||||
end
|
||||
169
gemfiles/Gemfile.rails-4.1-stable.lock
Normal file
169
gemfiles/Gemfile.rails-4.1-stable.lock
Normal file
@@ -0,0 +1,169 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/rails.git
|
||||
revision: bf32ec7b8611e6b4c7e9398f7d297a1f0221e9b9
|
||||
branch: 4-1-stable
|
||||
specs:
|
||||
actionmailer (4.1.10)
|
||||
actionpack (= 4.1.10)
|
||||
actionview (= 4.1.10)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
actionpack (4.1.10)
|
||||
actionview (= 4.1.10)
|
||||
activesupport (= 4.1.10)
|
||||
rack (~> 1.5.2)
|
||||
rack-test (~> 0.6.2)
|
||||
actionview (4.1.10)
|
||||
activesupport (= 4.1.10)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
activemodel (4.1.10)
|
||||
activesupport (= 4.1.10)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.1.10)
|
||||
activemodel (= 4.1.10)
|
||||
activesupport (= 4.1.10)
|
||||
arel (~> 5.0.0)
|
||||
activesupport (4.1.10)
|
||||
i18n (~> 0.6, >= 0.6.9)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo (~> 1.1)
|
||||
rails (4.1.10)
|
||||
actionmailer (= 4.1.10)
|
||||
actionpack (= 4.1.10)
|
||||
actionview (= 4.1.10)
|
||||
activemodel (= 4.1.10)
|
||||
activerecord (= 4.1.10)
|
||||
activesupport (= 4.1.10)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.1.10)
|
||||
sprockets-rails (~> 2.0)
|
||||
railties (4.1.10)
|
||||
actionpack (= 4.1.10)
|
||||
activesupport (= 4.1.10)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (3.4.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 3.2.6, < 5)
|
||||
responders
|
||||
thread_safe (~> 0.1)
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
arel (5.0.1.20140414130214)
|
||||
bcrypt (3.1.10)
|
||||
bson (2.3.0)
|
||||
builder (3.2.2)
|
||||
connection_pool (2.1.3)
|
||||
erubis (2.7.0)
|
||||
faraday (0.9.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
hashie (3.4.0)
|
||||
hike (1.2.3)
|
||||
i18n (0.7.0)
|
||||
json (1.8.2)
|
||||
jwt (1.4.1)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
metaclass (0.0.4)
|
||||
mime-types (2.4.3)
|
||||
mini_portile (0.6.2)
|
||||
minitest (5.5.1)
|
||||
mocha (1.1.0)
|
||||
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.4)
|
||||
bson (~> 2.2)
|
||||
connection_pool (~> 2.0)
|
||||
optionable (~> 0.2.0)
|
||||
multi_json (1.11.0)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.6.6.2)
|
||||
mini_portile (~> 0.6.0)
|
||||
oauth2 (0.9.4)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
jwt (~> 1.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (~> 1.2)
|
||||
omniauth (1.2.2)
|
||||
hashie (>= 1.2, < 4)
|
||||
rack (~> 1.0)
|
||||
omniauth-facebook (1.6.0)
|
||||
omniauth-oauth2 (~> 1.1)
|
||||
omniauth-oauth2 (1.1.2)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
multi_json (~> 1.3)
|
||||
oauth2 (~> 0.9.3)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
optionable (0.2.0)
|
||||
origin (2.1.1)
|
||||
orm_adapter (0.5.0)
|
||||
rack (1.5.2)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rake (10.4.2)
|
||||
rdoc (4.2.0)
|
||||
responders (1.1.2)
|
||||
railties (>= 3.2, < 4.2)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (2.12.3)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
sprockets-rails (2.2.4)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sqlite3 (1.3.10)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tilt (1.4.1)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
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 (~> 1.1)
|
||||
mongoid (~> 4.0.0)
|
||||
omniauth (~> 1.2.0)
|
||||
omniauth-facebook
|
||||
omniauth-oauth2 (~> 1.1.0)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
rails!
|
||||
rdoc
|
||||
sqlite3
|
||||
webrat (= 0.7.3)
|
||||
29
gemfiles/Gemfile.rails-4.2-stable
Normal file
29
gemfiles/Gemfile.rails-4.2-stable
Normal file
@@ -0,0 +1,29 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: '..'
|
||||
|
||||
gem "rails", github: 'rails/rails', branch: '4-2-stable'
|
||||
gem "omniauth", "~> 1.2.2"
|
||||
gem "omniauth-oauth2", "~> 1.2.0"
|
||||
gem "rdoc"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.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
|
||||
|
||||
group :mongoid do
|
||||
gem "mongoid", "~> 4.0.0"
|
||||
end
|
||||
191
gemfiles/Gemfile.rails-4.2-stable.lock
Normal file
191
gemfiles/Gemfile.rails-4.2-stable.lock
Normal file
@@ -0,0 +1,191 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/rails.git
|
||||
revision: f12ff8ddab7b199707ec36d72bd72f206f142c8b
|
||||
branch: 4-2-stable
|
||||
specs:
|
||||
actionmailer (4.2.1)
|
||||
actionpack (= 4.2.1)
|
||||
actionview (= 4.2.1)
|
||||
activejob (= 4.2.1)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
actionpack (4.2.1)
|
||||
actionview (= 4.2.1)
|
||||
activesupport (= 4.2.1)
|
||||
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.1)
|
||||
activesupport (= 4.2.1)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
activejob (4.2.1)
|
||||
activesupport (= 4.2.1)
|
||||
globalid (>= 0.3.0)
|
||||
activemodel (4.2.1)
|
||||
activesupport (= 4.2.1)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.2.1)
|
||||
activemodel (= 4.2.1)
|
||||
activesupport (= 4.2.1)
|
||||
arel (~> 6.0)
|
||||
activesupport (4.2.1)
|
||||
i18n (~> 0.7)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
rails (4.2.1)
|
||||
actionmailer (= 4.2.1)
|
||||
actionpack (= 4.2.1)
|
||||
actionview (= 4.2.1)
|
||||
activejob (= 4.2.1)
|
||||
activemodel (= 4.2.1)
|
||||
activerecord (= 4.2.1)
|
||||
activesupport (= 4.2.1)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.2.1)
|
||||
sprockets-rails
|
||||
railties (4.2.1)
|
||||
actionpack (= 4.2.1)
|
||||
activesupport (= 4.2.1)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (3.4.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 3.2.6, < 5)
|
||||
responders
|
||||
thread_safe (~> 0.1)
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
arel (6.0.0)
|
||||
bcrypt (3.1.10)
|
||||
bson (2.3.0)
|
||||
builder (3.2.2)
|
||||
connection_pool (2.1.3)
|
||||
erubis (2.7.0)
|
||||
faraday (0.9.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.3.3)
|
||||
activesupport (>= 4.1.0)
|
||||
hashie (3.4.0)
|
||||
hike (1.2.3)
|
||||
i18n (0.7.0)
|
||||
json (1.8.2)
|
||||
jwt (1.4.1)
|
||||
loofah (2.0.1)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
metaclass (0.0.4)
|
||||
mime-types (2.4.3)
|
||||
mini_portile (0.6.2)
|
||||
minitest (5.5.1)
|
||||
mocha (1.1.0)
|
||||
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.4)
|
||||
bson (~> 2.2)
|
||||
connection_pool (~> 2.0)
|
||||
optionable (~> 0.2.0)
|
||||
multi_json (1.11.0)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.6.6.2)
|
||||
mini_portile (~> 0.6.0)
|
||||
oauth2 (1.0.0)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
jwt (~> 1.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (~> 1.2)
|
||||
omniauth (1.2.2)
|
||||
hashie (>= 1.2, < 4)
|
||||
rack (~> 1.0)
|
||||
omniauth-facebook (2.0.1)
|
||||
omniauth-oauth2 (~> 1.2)
|
||||
omniauth-oauth2 (1.2.0)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
multi_json (~> 1.3)
|
||||
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.1.1)
|
||||
orm_adapter (0.5.0)
|
||||
rack (1.6.0)
|
||||
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.6)
|
||||
activesupport (>= 4.2.0.beta, < 5.0)
|
||||
nokogiri (~> 1.6.0)
|
||||
rails-deprecated_sanitizer (>= 1.0.1)
|
||||
rails-html-sanitizer (1.0.2)
|
||||
loofah (~> 2.0)
|
||||
rake (10.4.2)
|
||||
rdoc (4.2.0)
|
||||
responders (2.1.0)
|
||||
railties (>= 4.2.0, < 5)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (2.12.3)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.0)
|
||||
tilt (~> 1.1, != 1.3.0)
|
||||
sprockets-rails (2.2.4)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sqlite3 (1.3.10)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tilt (1.4.1)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
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 (~> 1.1)
|
||||
mongoid (~> 4.0.0)
|
||||
omniauth (~> 1.2.2)
|
||||
omniauth-facebook
|
||||
omniauth-oauth2 (~> 1.2.0)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
rails!
|
||||
rdoc
|
||||
sqlite3
|
||||
webrat (= 0.7.3)
|
||||
283
lib/devise.rb
283
lib/devise.rb
@@ -3,29 +3,35 @@ require 'active_support/core_ext/numeric/time'
|
||||
require 'active_support/dependencies'
|
||||
require 'orm_adapter'
|
||||
require 'set'
|
||||
require 'securerandom'
|
||||
require 'responders'
|
||||
|
||||
module Devise
|
||||
autoload :FailureApp, 'devise/failure_app'
|
||||
autoload :OmniAuth, 'devise/omniauth'
|
||||
autoload :PathChecker, 'devise/path_checker'
|
||||
autoload :Schema, 'devise/schema'
|
||||
autoload :TestHelpers, 'devise/test_helpers'
|
||||
autoload :Delegator, 'devise/delegator'
|
||||
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'
|
||||
|
||||
module Controllers
|
||||
autoload :Helpers, 'devise/controllers/helpers'
|
||||
autoload :InternalHelpers, 'devise/controllers/internal_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 Encryptors
|
||||
autoload :Base, 'devise/encryptors/base'
|
||||
autoload :AuthlogicSha512, 'devise/encryptors/authlogic_sha512'
|
||||
autoload :ClearanceSha1, 'devise/encryptors/clearance_sha1'
|
||||
autoload :RestfulAuthenticationSha1, 'devise/encryptors/restful_authentication_sha1'
|
||||
autoload :Sha512, 'devise/encryptors/sha512'
|
||||
autoload :Sha1, 'devise/encryptors/sha1'
|
||||
module Hooks
|
||||
autoload :Proxy, 'devise/hooks/proxy'
|
||||
end
|
||||
|
||||
module Mailers
|
||||
autoload :Helpers, 'devise/mailers/helpers'
|
||||
end
|
||||
|
||||
module Strategies
|
||||
@@ -41,38 +47,43 @@ module Devise
|
||||
STRATEGIES = ActiveSupport::OrderedHash.new
|
||||
URL_HELPERS = ActiveSupport::OrderedHash.new
|
||||
|
||||
# Strategies that do not require user input.
|
||||
NO_INPUT = []
|
||||
|
||||
# True values used to check params
|
||||
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE']
|
||||
|
||||
# Declare encryptors length which are used in migrations.
|
||||
ENCRYPTORS_LENGTH = {
|
||||
:sha1 => 40,
|
||||
:sha512 => 128,
|
||||
:clearance_sha1 => 40,
|
||||
:restful_authentication_sha1 => 40,
|
||||
:authlogic_sha512 => 128
|
||||
}
|
||||
# Secret key used by the key generator
|
||||
mattr_accessor :secret_key
|
||||
@@secret_key = nil
|
||||
|
||||
# Custom domain for cookies. Not set by default
|
||||
mattr_accessor :cookie_options
|
||||
@@cookie_options = {}
|
||||
# Custom domain or key for cookies. Not set by default
|
||||
mattr_accessor :rememberable_options
|
||||
@@rememberable_options = {}
|
||||
|
||||
# The number of times to encrypt password.
|
||||
mattr_accessor :stretches
|
||||
@@stretches = 10
|
||||
|
||||
# The default key used when authenticating over http auth.
|
||||
mattr_accessor :http_authentication_key
|
||||
@@http_authentication_key = nil
|
||||
|
||||
# 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
|
||||
@@request_keys = []
|
||||
|
||||
# Keys that should be case-insensitive.
|
||||
# Empty by default for backwards compatibility.
|
||||
mattr_accessor :case_insensitive_keys
|
||||
@@case_insensitive_keys = []
|
||||
@@case_insensitive_keys = [:email]
|
||||
|
||||
# Keys that should have whitespace stripped.
|
||||
mattr_accessor :strip_whitespace_keys
|
||||
@@strip_whitespace_keys = []
|
||||
|
||||
# If http authentication is enabled by default.
|
||||
mattr_accessor :http_authenticatable
|
||||
@@ -90,56 +101,58 @@ module Devise
|
||||
mattr_accessor :http_authentication_realm
|
||||
@@http_authentication_realm = "Application"
|
||||
|
||||
# Email regex used to validate email formats. Adapted from authlogic.
|
||||
# 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.
|
||||
mattr_accessor :email_regexp
|
||||
@@email_regexp = /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
|
||||
@@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
|
||||
|
||||
# Range validation for password length
|
||||
mattr_accessor :password_length
|
||||
@@password_length = 6..20
|
||||
@@password_length = 6..128
|
||||
|
||||
# The time the user will be remembered without asking for credentials again.
|
||||
mattr_accessor :remember_for
|
||||
@@remember_for = 2.weeks
|
||||
|
||||
# If true, a valid remember token can be re-used between multiple browsers.
|
||||
mattr_accessor :remember_across_browsers
|
||||
@@remember_across_browsers = true
|
||||
|
||||
# If true, extends the user's remember period when remembered via cookie.
|
||||
mattr_accessor :extend_remember_period
|
||||
@@extend_remember_period = false
|
||||
|
||||
# If true, uses salt as remember token and does not create it in the database.
|
||||
# By default is false for backwards compatibility.
|
||||
mattr_accessor :use_salt_as_remember_token
|
||||
@@use_salt_as_remember_token = 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.
|
||||
mattr_accessor :confirm_within
|
||||
@@confirm_within = 0.days
|
||||
# nil - allows unconfirmed access for unlimited time
|
||||
mattr_accessor :allow_unconfirmed_access_for
|
||||
@@allow_unconfirmed_access_for = 0.days
|
||||
|
||||
# Defines which key will be used when confirming an account
|
||||
# Time interval the confirmation token is valid. nil = unlimited
|
||||
mattr_accessor :confirm_within
|
||||
@@confirm_within = nil
|
||||
|
||||
# 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
|
||||
|
||||
# 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.
|
||||
mattr_accessor :pepper
|
||||
@@pepper = nil
|
||||
|
||||
# Used to define the password encryption algorithm.
|
||||
mattr_accessor :encryptor
|
||||
@@encryptor = nil
|
||||
|
||||
# Tells if devise should apply the schema in ORMs where devise declaration
|
||||
# and schema belongs to the same class (as Datamapper and Mongoid).
|
||||
mattr_accessor :apply_schema
|
||||
@@apply_schema = true
|
||||
|
||||
# Scoped views. Since it relies on fallbacks to render default views, it's
|
||||
# turned off by default.
|
||||
mattr_accessor :scoped_views
|
||||
@@ -152,7 +165,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
|
||||
@@ -169,7 +182,15 @@ 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
|
||||
@@ -179,18 +200,13 @@ 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
|
||||
|
||||
# If true, authentication through token does not store user in session
|
||||
mattr_accessor :stateless_token
|
||||
@@stateless_token = false
|
||||
# Skip session storage for the following strategies
|
||||
mattr_accessor :skip_session_storage
|
||||
@@skip_session_storage = []
|
||||
|
||||
# Which formats should be treated as navigational.
|
||||
# We need both :"*/*" and "*/*" to work on different Rails versions.
|
||||
mattr_accessor :navigational_formats
|
||||
@@navigational_formats = [:"*/*", "*/*", :html]
|
||||
@@navigational_formats = ["*/*", :html]
|
||||
|
||||
# When set to true, signing out a user signs out all other scopes.
|
||||
mattr_accessor :sign_out_all_scopes
|
||||
@@ -200,13 +216,40 @@ module Devise
|
||||
mattr_accessor :sign_out_via
|
||||
@@sign_out_via = :get
|
||||
|
||||
# The parent controller all Devise controllers inherits from.
|
||||
# Defaults to ApplicationController. This should be set early
|
||||
# in the initialization process and should be set to a string.
|
||||
mattr_accessor :parent_controller
|
||||
@@parent_controller = "ApplicationController"
|
||||
|
||||
# The parent mailer all Devise mailers inherit from.
|
||||
# Defaults to ActionMailer::Base. This should be set early
|
||||
# in the initialization process and should be set to a string.
|
||||
mattr_accessor :parent_mailer
|
||||
@@parent_mailer = "ActionMailer::Base"
|
||||
|
||||
# The router Devise should use to generate routes. Defaults
|
||||
# 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 overridden when
|
||||
# Devise is used in a mountable engine
|
||||
mattr_accessor :omniauth_path_prefix
|
||||
@@omniauth_path_prefix = nil
|
||||
|
||||
# Set if we should clean up the CSRF Token on authentication
|
||||
mattr_accessor :clean_up_csrf_token_on_authentication
|
||||
@@clean_up_csrf_token_on_authentication = true
|
||||
|
||||
# PRIVATE CONFIGURATION
|
||||
|
||||
# Store scopes mappings.
|
||||
mattr_reader :mappings
|
||||
@@mappings = ActiveSupport::OrderedHash.new
|
||||
|
||||
# Omniauth configurations.
|
||||
# OmniAuth configurations.
|
||||
mattr_reader :omniauth_configs
|
||||
@@omniauth_configs = ActiveSupport::OrderedHash.new
|
||||
|
||||
@@ -218,7 +261,19 @@ 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
|
||||
# a fresh initializer with all configuration values.
|
||||
@@ -226,14 +281,31 @@ module Devise
|
||||
yield self
|
||||
end
|
||||
|
||||
def self.omniauth_providers
|
||||
omniauth_configs.keys
|
||||
class Getter
|
||||
def initialize name
|
||||
@name = name
|
||||
end
|
||||
|
||||
def get
|
||||
ActiveSupport::Dependencies.constantize(@name)
|
||||
end
|
||||
end
|
||||
|
||||
def self.cookie_domain=(value)
|
||||
ActiveSupport::Deprecation.warn "Devise.cookie_domain=(value) is deprecated. "
|
||||
"Please use Devise.cookie_options = { :domain => value } instead."
|
||||
self.cookie_options[:domain] = value
|
||||
def self.ref(arg)
|
||||
if defined?(ActiveSupport::Dependencies::ClassCache)
|
||||
ActiveSupport::Dependencies::reference(arg)
|
||||
Getter.new(arg)
|
||||
else
|
||||
ActiveSupport::Dependencies.ref(arg)
|
||||
end
|
||||
end
|
||||
|
||||
def self.available_router_name
|
||||
router_name || :main_app
|
||||
end
|
||||
|
||||
def self.omniauth_providers
|
||||
omniauth_configs.keys
|
||||
end
|
||||
|
||||
# Get the mailer class from the mailer reference object.
|
||||
@@ -243,7 +315,7 @@ module Devise
|
||||
|
||||
# Set the mailer reference object to access the mailer.
|
||||
def self.mailer=(class_name)
|
||||
@@mailer_ref = ActiveSupport::Dependencies.ref(class_name)
|
||||
@@mailer_ref = ref(class_name)
|
||||
end
|
||||
self.mailer = "Devise::Mailer"
|
||||
|
||||
@@ -261,9 +333,10 @@ module Devise
|
||||
# == Options:
|
||||
#
|
||||
# +model+ - String representing the load path to a custom *model* for this module (to autoload.)
|
||||
# +controller+ - Symbol representing the name of an exisiting or custom *controller* for this module.
|
||||
# +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.
|
||||
@@ -271,21 +344,27 @@ 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)
|
||||
options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input, :insert_at)
|
||||
|
||||
ALL.insert (options[:insert_at] || -1), module_name
|
||||
|
||||
if strategy = options[:strategy]
|
||||
STRATEGIES[module_name] = (strategy == true ? module_name : strategy)
|
||||
strategy = (strategy == true ? module_name : strategy)
|
||||
STRATEGIES[module_name] = strategy
|
||||
end
|
||||
|
||||
if controller = options[:controller]
|
||||
CONTROLLERS[module_name] = (controller == true ? module_name : controller)
|
||||
controller = (controller == true ? module_name : controller)
|
||||
CONTROLLERS[module_name] = controller
|
||||
end
|
||||
|
||||
NO_INPUT << strategy if options[:no_input]
|
||||
|
||||
if route = options[:route]
|
||||
case route
|
||||
when TrueClass
|
||||
@@ -307,7 +386,8 @@ module Devise
|
||||
|
||||
if options[:model]
|
||||
path = (options[:model] == true ? "devise/models/#{module_name}" : options[:model])
|
||||
Devise::Models.send(:autoload, module_name.to_s.camelize.to_sym, path)
|
||||
camelized = ActiveSupport::Inflector.camelize(module_name.to_s)
|
||||
Devise::Models.send(:autoload, camelized.to_sym, path)
|
||||
end
|
||||
|
||||
Devise::Mapping.add_module module_name
|
||||
@@ -316,8 +396,8 @@ module Devise
|
||||
# Sets warden configuration using a block that will be invoked on warden
|
||||
# initialization.
|
||||
#
|
||||
# Devise.initialize do |config|
|
||||
# config.confirm_within = 2.days
|
||||
# Devise.setup do |config|
|
||||
# config.allow_unconfirmed_access_for = 2.days
|
||||
#
|
||||
# config.warden do |manager|
|
||||
# # Configure warden to use other strategies, like oauth.
|
||||
@@ -325,16 +405,17 @@ 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
|
||||
@@omniauth_configs[provider] = Devise::OmniAuth::Config.new(provider, args)
|
||||
config = Devise::OmniAuth::Config.new(provider, args)
|
||||
@@omniauth_configs[config.strategy_name.to_sym] = config
|
||||
end
|
||||
|
||||
# Include helpers in the given scope to AC and AV.
|
||||
@@ -349,31 +430,47 @@ module Devise
|
||||
end
|
||||
end
|
||||
|
||||
# Returns true if Rails version is bigger than 3.0.x
|
||||
def self.rack_session?
|
||||
Rails::VERSION::STRING[0,3] != "3.0"
|
||||
# Regenerates url helpers considering Devise.mapping
|
||||
def self.regenerate_helpers!
|
||||
Devise::Controllers::UrlHelpers.remove_helpers!
|
||||
Devise::Controllers::UrlHelpers.generate_helpers!
|
||||
end
|
||||
|
||||
# A method used internally to setup warden manager from the Rails initialize
|
||||
# block.
|
||||
def self.configure_warden! #:nodoc:
|
||||
@@warden_configured ||= begin
|
||||
warden_config.failure_app = Devise::FailureApp
|
||||
warden_config.failure_app = Devise::Delegator.new
|
||||
warden_config.default_scope = Devise.default_scope
|
||||
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]
|
||||
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 randomically to be used as token.
|
||||
def self.friendly_token
|
||||
ActiveSupport::SecureRandom.base64(15).tr('+/=', 'xyz')
|
||||
# Generate a friendly string randomly to be used as token.
|
||||
# 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
|
||||
|
||||
@@ -3,9 +3,80 @@ module Devise
|
||||
# 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?, :anybody_signed_in?
|
||||
helper_method :warden, :signed_in?, :devise_controller?
|
||||
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_filter :authenticate_blogger! # Redirects unless either a user or an admin are authenticated
|
||||
# before_filter ->{ 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
|
||||
|
||||
helper_method "current_#{group_name}", "current_#{group_name.to_s.pluralize}", "#{group_name}_signed_in?"
|
||||
METHODS
|
||||
end
|
||||
|
||||
def log_process_action(payload)
|
||||
payload[:status] ||= 401 unless payload[:exception]
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
# Define authentication filters and accessor helpers based on mappings.
|
||||
@@ -36,8 +107,9 @@ module Devise
|
||||
mapping = mapping.name
|
||||
|
||||
class_eval <<-METHODS, __FILE__, __LINE__ + 1
|
||||
def authenticate_#{mapping}!(force = false)
|
||||
warden.authenticate!(:scope => :#{mapping}) if !devise_controller? || force
|
||||
def authenticate_#{mapping}!(opts={})
|
||||
opts[:scope] = :#{mapping}
|
||||
warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
|
||||
end
|
||||
|
||||
def #{mapping}_signed_in?
|
||||
@@ -45,7 +117,7 @@ module Devise
|
||||
end
|
||||
|
||||
def current_#{mapping}
|
||||
@current_#{mapping} ||= warden.authenticate(:scope => :#{mapping})
|
||||
@current_#{mapping} ||= warden.authenticate(scope: :#{mapping})
|
||||
end
|
||||
|
||||
def #{mapping}_session
|
||||
@@ -67,122 +139,77 @@ module Devise
|
||||
# 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 => { |c| c.devise_controller? }
|
||||
# before_filter :my_filter, unless: :devise_controller?
|
||||
def devise_controller?
|
||||
false
|
||||
is_a?(::DeviseController)
|
||||
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
|
||||
|
||||
def anybody_signed_in?
|
||||
ActiveSupport::Deprecation.warn "Devise#anybody_signed_in? is deprecated. "
|
||||
"Please use Devise#signed_in?(nil) instead."
|
||||
signed_in?
|
||||
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, :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.
|
||||
# Setup 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
|
||||
warden.set_user(resource, options.merge!(:scope => scope))
|
||||
Devise::BaseSanitizer.new(resource_class, resource_name, params)
|
||||
end
|
||||
end
|
||||
|
||||
# Sign out a given user or scope. This helper is useful for signing out a user
|
||||
# after deleting accounts.
|
||||
#
|
||||
# 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)
|
||||
warden.user(scope) # Without loading user here, before_logout hook is not called
|
||||
warden.raw_session.inspect # Without this inspect here. The session does not clear.
|
||||
warden.logout(scope)
|
||||
# Tell warden that params authentication is allowed for that specific page.
|
||||
def allow_params_authentication!
|
||||
request.env["devise.allow_params_authentication"] = true
|
||||
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.
|
||||
def sign_out_all_scopes
|
||||
Devise.mappings.keys.each { |s| warden.user(s) }
|
||||
warden.raw_session.inspect
|
||||
warden.logout
|
||||
end
|
||||
|
||||
# Returns and delete 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)
|
||||
# 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)
|
||||
session.delete("#{scope}_return_to")
|
||||
router_name = Devise.mappings[scope].router_name
|
||||
|
||||
home_path = "#{scope}_root_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
|
||||
"/"
|
||||
end
|
||||
end
|
||||
|
||||
# The default url to be used after signing in. This is used by all Devise
|
||||
# controllers and you can overwrite it in your ApplicationController to
|
||||
# provide a custom hook for a custom resource.
|
||||
#
|
||||
# By default, it first tries to find a resource_root_path, otherwise it
|
||||
# uses the root path. For a user scope, you can define the default url in
|
||||
# By default, it first tries to find a valid resource_return_to key in the
|
||||
# session, then it fallbacks to resource_root_path, otherwise it uses the
|
||||
# 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
|
||||
# map.user_root '/users', controller: 'users' # creates user_root_path
|
||||
#
|
||||
# map.namespace :user do |user|
|
||||
# user.root :controller => 'users' # creates user_root_path
|
||||
# user.root controller: 'users' # creates user_root_path
|
||||
# end
|
||||
#
|
||||
#
|
||||
# If the resource root path is not defined, root_path is used. However,
|
||||
# if this default is not enough, you can customize it, for example:
|
||||
#
|
||||
# def after_sign_in_path_for(resource)
|
||||
# if resource.is_a?(User) && resource.can_publish?
|
||||
# publisher_url
|
||||
# else
|
||||
# super
|
||||
# end
|
||||
# stored_location_for(resource) ||
|
||||
# if resource.is_a?(User) && resource.can_publish?
|
||||
# publisher_url
|
||||
# else
|
||||
# super
|
||||
# end
|
||||
# end
|
||||
#
|
||||
def after_sign_in_path_for(resource_or_scope)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
home_path = "#{scope}_root_path"
|
||||
respond_to?(home_path, true) ? send(home_path) : root_path
|
||||
stored_location_for(resource_or_scope) || signed_in_root_path(resource_or_scope)
|
||||
end
|
||||
|
||||
# Method used by sessions controller to sign out a user. You can overwrite
|
||||
@@ -190,9 +217,12 @@ module Devise
|
||||
# scope. Notice that differently from +after_sign_in_path_for+ this method
|
||||
# receives a symbol with the scope, and not the resource.
|
||||
#
|
||||
# By default is the root_path.
|
||||
# By default it is the root_path.
|
||||
def after_sign_out_path_for(resource_or_scope)
|
||||
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
|
||||
@@ -203,31 +233,51 @@ module Devise
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
resource = args.last || resource_or_scope
|
||||
sign_in(scope, resource, options)
|
||||
redirect_to redirect_location(scope, resource)
|
||||
end
|
||||
|
||||
def redirect_location(scope, resource) #:nodoc:
|
||||
stored_location_for(scope) || after_sign_in_path_for(resource)
|
||||
redirect_to after_sign_in_path_for(resource)
|
||||
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)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
redirect_path = after_sign_out_path_for(scope)
|
||||
Devise.sign_out_all_scopes ? sign_out : sign_out(scope)
|
||||
redirect_to after_sign_out_path_for(scope)
|
||||
redirect_to redirect_path
|
||||
end
|
||||
|
||||
# A hook called to expire session data after sign up/in. All keys
|
||||
# stored under "devise." namespace are removed after sign in.
|
||||
def expire_session_data_after_sign_in!
|
||||
session.keys.grep(/^devise\./).each { |k| session.delete(k) }
|
||||
end
|
||||
|
||||
# Overwrite Rails' handle unverified request to sign out all scopes.
|
||||
# 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
|
||||
super # call the default behaviour which resets the session
|
||||
super # call the default behaviour which resets/nullifies/raises
|
||||
request.env["devise.skip_storage"] = true
|
||||
sign_out_all_scopes(false)
|
||||
end
|
||||
|
||||
def request_format
|
||||
@request_format ||= request.format.try(:ref)
|
||||
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?
|
||||
is_navigational_format?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def expire_session_data_after_sign_in!
|
||||
ActiveSupport::Deprecation.warn "expire_session_data_after_sign_in! is deprecated " \
|
||||
"in favor of expire_data_after_sign_in!"
|
||||
expire_data_after_sign_in!
|
||||
end
|
||||
|
||||
def expire_data_after_sign_out!
|
||||
Devise.mappings.each { |_,m| instance_variable_set("@current_#{m.name}", nil) }
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
module Devise
|
||||
module Controllers
|
||||
# Those helpers are used only inside Devise controllers and should not be
|
||||
# included in ApplicationController since they all depend on the url being
|
||||
# accessed.
|
||||
module InternalHelpers #:nodoc:
|
||||
extend ActiveSupport::Concern
|
||||
include Devise::Controllers::ScopedViews
|
||||
|
||||
included do
|
||||
helper DeviseHelper
|
||||
|
||||
helpers = %w(resource scope_name resource_name signed_in_resource
|
||||
resource_class devise_mapping devise_controller?)
|
||||
hide_action *helpers
|
||||
helper_method *helpers
|
||||
|
||||
prepend_before_filter :is_devise_resource?
|
||||
respond_to *Mime::SET.map(&:to_sym) if mimes_for_respond_to.empty?
|
||||
end
|
||||
|
||||
# Gets the actual resource stored in the instance variable
|
||||
def resource
|
||||
instance_variable_get(:"@#{resource_name}")
|
||||
end
|
||||
|
||||
# Proxy to devise map name
|
||||
def resource_name
|
||||
devise_mapping.name
|
||||
end
|
||||
alias :scope_name :resource_name
|
||||
|
||||
# Proxy to devise map class
|
||||
def resource_class
|
||||
devise_mapping.to
|
||||
end
|
||||
|
||||
# Returns a signed in resource from session (if one exists)
|
||||
def signed_in_resource
|
||||
warden.authenticate(:scope => resource_name)
|
||||
end
|
||||
|
||||
# Attempt to find the mapped route for devise based on request path
|
||||
def devise_mapping
|
||||
@devise_mapping ||= request.env["devise.mapping"]
|
||||
end
|
||||
|
||||
# Overwrites devise_controller? to return true
|
||||
def devise_controller?
|
||||
true
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Checks whether it's a devise mapped resource or not.
|
||||
def is_devise_resource? #:nodoc:
|
||||
unknown_action!("Could not find devise mapping for path #{request.fullpath.inspect}") unless devise_mapping
|
||||
end
|
||||
|
||||
# Check whether it's navigational format, such as :html or :iphone, or not.
|
||||
def is_navigational_format?
|
||||
Devise.navigational_formats.include?(request.format.to_sym)
|
||||
end
|
||||
|
||||
def unknown_action!(msg)
|
||||
logger.debug "[Devise] #{msg}" if logger
|
||||
raise ActionController::UnknownAction, msg
|
||||
end
|
||||
|
||||
# Sets the resource creating an instance variable
|
||||
def resource=(new_resource)
|
||||
instance_variable_set(:"@#{resource_name}", new_resource)
|
||||
end
|
||||
|
||||
# Build a devise resource.
|
||||
def build_resource(hash=nil)
|
||||
hash ||= params[resource_name] || {}
|
||||
self.resource = resource_class.new(hash)
|
||||
end
|
||||
|
||||
# Helper for use in before_filters where no authentication is required.
|
||||
#
|
||||
# Example:
|
||||
# before_filter :require_no_authentication, :only => :new
|
||||
def require_no_authentication
|
||||
if warden.authenticated?(resource_name)
|
||||
resource = warden.user(resource_name)
|
||||
redirect_to after_sign_in_path_for(resource)
|
||||
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.
|
||||
# Example (i18n locale file):
|
||||
#
|
||||
# en:
|
||||
# devise:
|
||||
# passwords:
|
||||
# #default_scope_messages - only if resource_scope is not found
|
||||
# user:
|
||||
# #resource_scope_messages
|
||||
#
|
||||
# Please refer to README or en.yml locale file to check what messages are
|
||||
# available.
|
||||
def set_flash_message(key, kind, options={}) #:nodoc:
|
||||
options[:scope] = "devise.#{controller_name}"
|
||||
options[:default] = Array(options[:default]).unshift(kind.to_sym)
|
||||
options[:resource_name] = resource_name
|
||||
message = I18n.t("#{resource_name}.#{kind}", options)
|
||||
flash[key] = message if message.present?
|
||||
end
|
||||
|
||||
def clean_up_passwords(object) #:nodoc:
|
||||
object.clean_up_passwords if object.respond_to?(:clean_up_passwords)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,52 +1,47 @@
|
||||
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
|
||||
end
|
||||
|
||||
# Remembers the given resource by setting up a cookie
|
||||
def remember_me(resource)
|
||||
return if env["devise.skip_storage"]
|
||||
scope = Devise::Mapping.find_scope!(resource)
|
||||
resource.remember_me!(resource.extend_remember_period)
|
||||
cookies.signed["remember_#{scope}_token"] = remember_cookie_values(resource)
|
||||
cookies.signed[remember_key(resource, scope)] = remember_cookie_values(resource)
|
||||
end
|
||||
|
||||
# Forgets the given resource by deleting a cookie
|
||||
def forget_me(resource)
|
||||
scope = Devise::Mapping.find_scope!(resource)
|
||||
resource.forget_me! unless resource.frozen?
|
||||
cookies.delete("remember_#{scope}_token", forget_cookie_values(resource))
|
||||
resource.forget_me!
|
||||
cookies.delete(remember_key(resource, scope), forget_cookie_values(resource))
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def forget_cookie_values(resource)
|
||||
Devise::Controllers::Rememberable.cookie_values.merge!(resource.cookie_options)
|
||||
Devise::Controllers::Rememberable.cookie_values.merge!(resource.rememberable_options)
|
||||
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
|
||||
|
||||
def remember_key(resource, scope)
|
||||
resource.rememberable_options.fetch(:key, "remember_#{scope}_token")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,22 +12,6 @@ module Devise
|
||||
@scoped_views = value
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Render a view for the specified scope. Turned off by default.
|
||||
# Accepts just :controller as option.
|
||||
def render_with_scope(action, path=self.controller_path)
|
||||
if self.class.scoped_views?
|
||||
begin
|
||||
render :template => "#{devise_mapping.scoped_path}/#{path.split("/").last}/#{action}"
|
||||
rescue ActionView::MissingTemplate
|
||||
render :template => "#{path}/#{action}"
|
||||
end
|
||||
else
|
||||
render :template => "#{path}/#{action}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
102
lib/devise/controllers/sign_in_out.rb
Normal file
102
lib/devise/controllers/sign_in_out.rb
Normal file
@@ -0,0 +1,102 @@
|
||||
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. 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_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.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
|
||||
|
||||
def expire_data_after_sign_out!
|
||||
# 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
|
||||
end
|
||||
end
|
||||
end
|
||||
58
lib/devise/controllers/store_location.rb
Normal file
58
lib/devise/controllers/store_location.rb
Normal file
@@ -0,0 +1,58 @@
|
||||
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_omniauth_authorize_path(:facebook)
|
||||
#
|
||||
def store_location_for(resource_or_scope, location)
|
||||
session_key = stored_location_key_for(resource_or_scope)
|
||||
uri = parse_uri(location)
|
||||
if uri
|
||||
path = [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')
|
||||
path = [path, uri.fragment].compact.join('#')
|
||||
session[session_key] = path
|
||||
end
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -16,24 +16,52 @@ module Devise
|
||||
# new_confirmation_path(:user) => new_user_confirmation_path
|
||||
# confirmation_path(:user) => user_confirmation_path
|
||||
#
|
||||
# Those helpers are added to your ApplicationController.
|
||||
# Those helpers are included by default to ActionController::Base.
|
||||
#
|
||||
# In case you want to add such helpers to another class, you can do
|
||||
# that as long as this new class includes both url_helpers and
|
||||
# mounted_helpers. Example:
|
||||
#
|
||||
# include Rails.application.routes.url_helpers
|
||||
# include Rails.application.routes.mounted_helpers
|
||||
#
|
||||
module UrlHelpers
|
||||
def self.remove_helpers!
|
||||
self.instance_methods.map(&:to_s).grep(/_(url|path)$/).each do |method|
|
||||
remove_method method
|
||||
end
|
||||
end
|
||||
|
||||
Devise::URL_HELPERS.each do |module_name, actions|
|
||||
[:path, :url].each do |path_or_url|
|
||||
actions.each do |action|
|
||||
action = action ? "#{action}_" : ""
|
||||
def self.generate_helpers!(routes=nil)
|
||||
routes ||= begin
|
||||
mappings = Devise.mappings.values.map(&:used_helpers).flatten.uniq
|
||||
Devise::URL_HELPERS.slice(*mappings)
|
||||
end
|
||||
|
||||
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
|
||||
def #{action}#{module_name}_#{path_or_url}(resource_or_scope, *args)
|
||||
routes.each do |module_name, actions|
|
||||
[:path, :url].each do |path_or_url|
|
||||
actions.each do |action|
|
||||
action = action ? "#{action}_" : ""
|
||||
method = :"#{action}#{module_name}_#{path_or_url}"
|
||||
|
||||
define_method method do |resource_or_scope, *args|
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
send("#{action}\#{scope}_#{module_name}_#{path_or_url}", *args)
|
||||
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
|
||||
URL_HELPERS
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
generate_helpers!(Devise::URL_HELPERS)
|
||||
|
||||
private
|
||||
|
||||
def _devise_route_context
|
||||
@_devise_route_context ||= send(Devise.available_router_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
16
lib/devise/delegator.rb
Normal file
16
lib/devise/delegator.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
module Devise
|
||||
# Checks the scope in the given environment and returns the associated failure app.
|
||||
class Delegator
|
||||
def call(env)
|
||||
failure_app(env).call(env)
|
||||
end
|
||||
|
||||
def failure_app(env)
|
||||
app = env["warden.options"] &&
|
||||
(scope = env["warden.options"][:scope]) &&
|
||||
Devise.mappings[scope.to_sym].failure_app
|
||||
|
||||
app || Devise::FailureApp
|
||||
end
|
||||
end
|
||||
end
|
||||
22
lib/devise/encryptor.rb
Normal file
22
lib/devise/encryptor.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
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, encrypted_password, password)
|
||||
return false if encrypted_password.blank?
|
||||
bcrypt = ::BCrypt::Password.new(encrypted_password)
|
||||
if klass.pepper.present?
|
||||
password = "#{password}#{klass.pepper}"
|
||||
end
|
||||
password = ::BCrypt::Engine.hash_secret(password, bcrypt.salt)
|
||||
Devise.secure_compare(password, encrypted_password)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,19 +0,0 @@
|
||||
require "digest/sha2"
|
||||
|
||||
module Devise
|
||||
module Encryptors
|
||||
# = AuthlogicSha512
|
||||
# Simulates Authlogic's default encryption mechanism.
|
||||
# Warning: it uses Devise's stretches configuration to port Authlogic's one. Should be set to 20 in the initializer to simulate
|
||||
# the default behavior.
|
||||
class AuthlogicSha512 < Base
|
||||
# Gererates a default password digest based on salt, pepper and the
|
||||
# incoming password.
|
||||
def self.digest(password, stretches, salt, pepper)
|
||||
digest = [password, salt].flatten.join('')
|
||||
stretches.times { digest = Digest::SHA512.hexdigest(digest) }
|
||||
digest
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,20 +0,0 @@
|
||||
module Devise
|
||||
# Implements a way of adding different encryptions.
|
||||
# The class should implement a self.digest method that taks the following params:
|
||||
# - password
|
||||
# - stretches: the number of times the encryption will be applied
|
||||
# - salt: the password salt as defined by devise
|
||||
# - pepper: Devise config option
|
||||
#
|
||||
module Encryptors
|
||||
class Base
|
||||
def self.digest
|
||||
raise NotImplemented
|
||||
end
|
||||
|
||||
def self.salt(stretches)
|
||||
Devise.friendly_token[0,20]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,17 +0,0 @@
|
||||
require "digest/sha1"
|
||||
|
||||
module Devise
|
||||
module Encryptors
|
||||
# = ClearanceSha1
|
||||
# Simulates Clearance's default encryption mechanism.
|
||||
# Warning: it uses Devise's pepper to port the concept of REST_AUTH_SITE_KEY
|
||||
# Warning: it uses Devise's stretches configuration to port the concept of REST_AUTH_DIGEST_STRETCHES
|
||||
class ClearanceSha1 < Base
|
||||
# Gererates a default password digest based on salt, pepper and the
|
||||
# incoming password.
|
||||
def self.digest(password, stretches, salt, pepper)
|
||||
Digest::SHA1.hexdigest("--#{salt}--#{password}--")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,22 +0,0 @@
|
||||
require "digest/sha1"
|
||||
|
||||
module Devise
|
||||
module Encryptors
|
||||
# = RestfulAuthenticationSha1
|
||||
# Simulates Restful Authentication's default encryption mechanism.
|
||||
# Warning: it uses Devise's pepper to port the concept of REST_AUTH_SITE_KEY
|
||||
# Warning: it uses Devise's stretches configuration to port the concept of REST_AUTH_DIGEST_STRETCHES. Should be set to 10 in
|
||||
# the initializer to simulate the default behavior.
|
||||
class RestfulAuthenticationSha1 < Base
|
||||
|
||||
# Gererates a default password digest based on salt, pepper and the
|
||||
# incoming password.
|
||||
def self.digest(password, stretches, salt, pepper)
|
||||
digest = pepper
|
||||
stretches.times { digest = Digest::SHA1.hexdigest([digest, salt, password, pepper].flatten.join('--')) }
|
||||
digest
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,25 +0,0 @@
|
||||
require "digest/sha1"
|
||||
|
||||
module Devise
|
||||
module Encryptors
|
||||
# = Sha1
|
||||
# Uses the Sha1 hash algorithm to encrypt passwords.
|
||||
class Sha1 < Base
|
||||
# Gererates a default password digest based on stretches, salt, pepper and the
|
||||
# incoming password.
|
||||
def self.digest(password, stretches, salt, pepper)
|
||||
digest = pepper
|
||||
stretches.times { digest = self.secure_digest(salt, digest, password, pepper) }
|
||||
digest
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Generate a SHA1 digest joining args. Generated token is something like
|
||||
# --arg1--arg2--arg3--argN--
|
||||
def self.secure_digest(*tokens)
|
||||
::Digest::SHA1.hexdigest('--' << tokens.flatten.join('--') << '--')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,25 +0,0 @@
|
||||
require "digest/sha2"
|
||||
|
||||
module Devise
|
||||
module Encryptors
|
||||
# = Sha512
|
||||
# Uses the Sha512 hash algorithm to encrypt passwords.
|
||||
class Sha512 < Base
|
||||
# Gererates a default password digest based on salt, pepper and the
|
||||
# incoming password.
|
||||
def self.digest(password, stretches, salt, pepper)
|
||||
digest = pepper
|
||||
stretches.times { digest = self.secure_digest(salt, digest, password, pepper) }
|
||||
digest
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Generate a Sha512 digest joining args. Generated token is something like
|
||||
# --arg1--arg2--arg3--argN--
|
||||
def self.secure_digest(*tokens)
|
||||
::Digest::SHA512.hexdigest('--' << tokens.flatten.join('--') << '--')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -9,16 +9,25 @@ module Devise
|
||||
include ActionController::RackDelegation
|
||||
include ActionController::UrlFor
|
||||
include ActionController::Redirecting
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
delegate :flash, :to => :request
|
||||
include Rails.application.routes.url_helpers
|
||||
include Rails.application.routes.mounted_helpers
|
||||
|
||||
include Devise::Controllers::StoreLocation
|
||||
|
||||
delegate :flash, to: :request
|
||||
|
||||
def self.call(env)
|
||||
action(:respond).call(env)
|
||||
@respond ||= action(:respond)
|
||||
@respond.call(env)
|
||||
end
|
||||
|
||||
def self.default_url_options(*args)
|
||||
ApplicationController.default_url_options(*args)
|
||||
if defined?(ApplicationController)
|
||||
ApplicationController.default_url_options(*args)
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
def respond
|
||||
@@ -40,37 +49,95 @@ module Devise
|
||||
|
||||
def recall
|
||||
env["PATH_INFO"] = attempted_path
|
||||
flash.now[:alert] = i18n_message(:invalid)
|
||||
flash.now[:alert] = i18n_message(:invalid) if is_flashing_format?
|
||||
self.response = recall_app(warden_options[:recall]).call(env)
|
||||
end
|
||||
|
||||
def redirect
|
||||
store_location!
|
||||
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 || warden_options[:message] || default || :unauthenticated
|
||||
message = warden_message || default || :unauthenticated
|
||||
|
||||
if message.is_a?(Symbol)
|
||||
I18n.t(:"#{scope}.#{message}", :resource_name => scope,
|
||||
:scope => "devise.failure", :default => [message, message.to_s])
|
||||
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
|
||||
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
|
||||
end
|
||||
|
||||
def redirect_url
|
||||
if request_format == :html
|
||||
send(:"new_#{scope}_session_path")
|
||||
if warden_message == :timeout
|
||||
flash[:timedout] = true if is_flashing_format?
|
||||
|
||||
path = if request.get?
|
||||
attempted_path
|
||||
else
|
||||
request.referrer
|
||||
end
|
||||
|
||||
path || scope_url
|
||||
else
|
||||
send(:"new_#{scope}_session_path", :format => request_format)
|
||||
scope_url
|
||||
end
|
||||
end
|
||||
|
||||
def route(scope)
|
||||
:"new_#{scope}_session_url"
|
||||
end
|
||||
|
||||
def scope_url
|
||||
opts = {}
|
||||
route = route(scope)
|
||||
opts[:format] = request_format unless skip_format?
|
||||
|
||||
config = Rails.application.config
|
||||
|
||||
if config.respond_to?(:relative_url_root) && config.relative_url_root.present?
|
||||
opts[:script_name] = config.relative_url_root
|
||||
end
|
||||
|
||||
router_name = Devise.mappings[scope].router_name || Devise.available_router_name
|
||||
context = send(router_name)
|
||||
|
||||
if context.respond_to?(route)
|
||||
context.send(route, opts)
|
||||
elsif respond_to?(:root_url)
|
||||
root_url(opts)
|
||||
else
|
||||
"/"
|
||||
end
|
||||
end
|
||||
|
||||
def skip_format?
|
||||
%w(html */*).include? request_format.to_s
|
||||
end
|
||||
|
||||
# Choose whether we should respond in a http authentication fashion,
|
||||
# including 401 and optional headers.
|
||||
#
|
||||
@@ -83,25 +150,33 @@ module Devise
|
||||
if request.xhr?
|
||||
Devise.http_authenticatable_on_xhr
|
||||
else
|
||||
!(request_format && Devise.navigational_formats.include?(request_format))
|
||||
!(request_format && is_navigational_format?)
|
||||
end
|
||||
end
|
||||
|
||||
# It does not 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}"
|
||||
{}.respond_to?(method) ? { :error => i18n_message }.send(method) : i18n_message
|
||||
if method == "to_xml"
|
||||
{ error: i18n_message }.to_xml(root: "errors")
|
||||
elsif {}.respond_to?(method)
|
||||
{ error: i18n_message }.send(method)
|
||||
else
|
||||
i18n_message
|
||||
end
|
||||
end
|
||||
|
||||
def recall_app(app)
|
||||
controller, action = app.split("#")
|
||||
"#{controller.camelize}Controller".constantize.action(action)
|
||||
controller_name = ActiveSupport::Inflector.camelize(controller)
|
||||
controller_klass = ActiveSupport::Inflector.constantize("#{controller_name}Controller")
|
||||
controller_klass.action(action)
|
||||
end
|
||||
|
||||
def warden
|
||||
@@ -112,10 +187,18 @@ module Devise
|
||||
env['warden.options']
|
||||
end
|
||||
|
||||
def warden_message
|
||||
@message ||= warden.message || warden_options[:message]
|
||||
end
|
||||
|
||||
def scope
|
||||
@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
|
||||
@@ -125,19 +208,21 @@ module Devise
|
||||
# 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
|
||||
|
||||
MIME_REFERENCES = Mime::HTML.respond_to?(:ref)
|
||||
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?
|
||||
is_navigational_format?
|
||||
end
|
||||
|
||||
def request_format
|
||||
@request_format ||= if request.format.respond_to?(:ref)
|
||||
request.format.ref
|
||||
elsif MIME_REFERENCES
|
||||
request.format
|
||||
else # Rails < 3.0.4
|
||||
request.format.to_sym
|
||||
end
|
||||
@request_format ||= request.format.try(:ref)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
# 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?
|
||||
# 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.
|
||||
# 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?) && !record.active?
|
||||
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
|
||||
|
||||
7
lib/devise/hooks/csrf_cleaner.rb
Normal file
7
lib/devise/hooks/csrf_cleaner.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
Warden::Manager.after_authentication do |record, warden, options|
|
||||
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,9 @@
|
||||
# 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 frozen.
|
||||
# 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
|
||||
|
||||
7
lib/devise/hooks/lockable.rb
Normal file
7
lib/devise/hooks/lockable.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# 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|
|
||||
if record.respond_to?(:failed_attempts) && warden.authenticated?(options[:scope])
|
||||
record.update_attribute(:failed_attempts, 0) unless record.failed_attempts.to_i.zero?
|
||||
end
|
||||
end
|
||||
21
lib/devise/hooks/proxy.rb
Normal file
21
lib/devise/hooks/proxy.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
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, :env, to: :warden
|
||||
|
||||
def initialize(warden)
|
||||
@warden = warden
|
||||
end
|
||||
|
||||
def session
|
||||
warden.request.session
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,7 @@
|
||||
Warden::Manager.after_set_user :except => :fetch do |record, warden, options|
|
||||
Warden::Manager.after_set_user except: :fetch do |record, warden, options|
|
||||
scope = options[:scope]
|
||||
if record.respond_to?(:remember_me) && record.remember_me && warden.authenticated?(scope)
|
||||
Devise::Controllers::Rememberable::Proxy.new(warden).remember_me(record)
|
||||
if record.respond_to?(:remember_me) && options[:store] != false &&
|
||||
record.remember_me && warden.authenticated?(scope)
|
||||
Devise::Hooks::Proxy.new(warden).remember_me(record)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,22 +1,35 @@
|
||||
# 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
|
||||
# record is set, we set the last request time inside it's scoped session to
|
||||
# record is set, we set the last request time inside its scoped session to
|
||||
# verify timeout in the following request.
|
||||
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
|
||||
last_request_at = warden.session(scope)['last_request_at']
|
||||
|
||||
if record.timedout?(last_request_at)
|
||||
path_checker = Devise::PathChecker.new(warden.env, scope)
|
||||
unless path_checker.signing_out?
|
||||
warden.logout(scope)
|
||||
throw :warden, :scope => scope, :message => :timeout
|
||||
end
|
||||
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
|
||||
|
||||
warden.session(scope)['last_request_at'] = Time.now.utc
|
||||
proxy = Devise::Hooks::Proxy.new(warden)
|
||||
|
||||
if record.timedout?(last_request_at) && !env['devise.skip_timeout']
|
||||
Devise.sign_out_all_scopes ? proxy.sign_out : proxy.sign_out(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
|
||||
end
|
||||
|
||||
unless env['devise.skip_trackable']
|
||||
warden.session(scope)['last_request_at'] = Time.now.utc.to_i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# 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|
|
||||
if record.respond_to?(:update_tracked_fields!) && warden.authenticated?(options[:scope])
|
||||
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
|
||||
end
|
||||
|
||||
90
lib/devise/mailers/helpers.rb
Normal file
90
lib/devise/mailers/helpers.rb
Normal file
@@ -0,0 +1,90 @@
|
||||
module Devise
|
||||
module Mailers
|
||||
module Helpers
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
include Devise::Controllers::ScopedViews
|
||||
attr_reader :scope_name, :resource
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Configure default email options
|
||||
def devise_mail(record, action, opts={})
|
||||
initialize_from_record(record)
|
||||
mail headers_for(action, opts)
|
||||
end
|
||||
|
||||
def initialize_from_record(record)
|
||||
@scope_name = Devise::Mapping.find_scope!(record)
|
||||
@resource = instance_variable_set("@#{devise_mapping.name}", record)
|
||||
end
|
||||
|
||||
def devise_mapping
|
||||
@devise_mapping ||= Devise.mappings[scope_name]
|
||||
end
|
||||
|
||||
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
|
||||
}.merge(opts)
|
||||
|
||||
@email = headers[:to]
|
||||
headers
|
||||
end
|
||||
|
||||
def mailer_reply_to(mapping)
|
||||
mailer_sender(mapping, :reply_to)
|
||||
end
|
||||
|
||||
def mailer_from(mapping)
|
||||
mailer_sender(mapping, :from)
|
||||
end
|
||||
|
||||
def mailer_sender(mapping, sender = :from)
|
||||
default_sender = default_params[sender]
|
||||
if default_sender.present?
|
||||
default_sender.respond_to?(:to_proc) ? instance_eval(&default_sender) : default_sender
|
||||
elsif Devise.mailer_sender.is_a?(Proc)
|
||||
Devise.mailer_sender.call(mapping.name)
|
||||
else
|
||||
Devise.mailer_sender
|
||||
end
|
||||
end
|
||||
|
||||
def template_paths
|
||||
template_path = _prefixes.dup
|
||||
template_path.unshift "#{@devise_mapping.scoped_path}/mailer" if self.class.scoped_views?
|
||||
template_path
|
||||
end
|
||||
|
||||
# Setup a subject doing an I18n lookup. At first, it attempts to set a subject
|
||||
# based on the current mapping:
|
||||
#
|
||||
# en:
|
||||
# devise:
|
||||
# mailer:
|
||||
# confirmation_instructions:
|
||||
# user_subject: '...'
|
||||
#
|
||||
# If one does not exist, it fallbacks to ActionMailer default:
|
||||
#
|
||||
# en:
|
||||
# devise:
|
||||
# mailer:
|
||||
# confirmation_instructions:
|
||||
# subject: '...'
|
||||
#
|
||||
def subject_for(key)
|
||||
I18n.t(:"#{devise_mapping.name}_subject", scope: [:devise, :mailer, key],
|
||||
default: [:subject, key.to_s.humanize])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -22,22 +22,26 @@ module Devise
|
||||
# # is the modules included in the class
|
||||
#
|
||||
class Mapping #:nodoc:
|
||||
attr_reader :singular, :scoped_path, :path, :controllers, :path_names, :class_name, :sign_out_via
|
||||
attr_reader :singular, :scoped_path, :path, :controllers, :path_names,
|
||||
: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!(duck)
|
||||
case duck
|
||||
def self.find_scope!(obj)
|
||||
obj = obj.devise_scope if obj.respond_to?(:devise_scope)
|
||||
case obj
|
||||
when String, Symbol
|
||||
return duck
|
||||
return obj.to_sym
|
||||
when Class
|
||||
Devise.mappings.each_value { |m| return m.name if duck <= m.to }
|
||||
Devise.mappings.each_value { |m| return m.name if obj <= m.to }
|
||||
else
|
||||
Devise.mappings.each_value { |m| return m.name if duck.is_a?(m.to) }
|
||||
Devise.mappings.each_value { |m| return m.name if obj.is_a?(m.to) }
|
||||
end
|
||||
|
||||
raise "Could not find a valid mapping for #{duck.inspect}"
|
||||
raise "Could not find a valid mapping for #{obj.inspect}"
|
||||
end
|
||||
|
||||
def self.find_by_path!(path, path_type=:fullpath)
|
||||
@@ -50,20 +54,21 @@ module Devise
|
||||
@singular = (options[:singular] || @scoped_path.tr('/', '_').singularize).to_sym
|
||||
|
||||
@class_name = (options[:class_name] || name.to_s.classify).to_s
|
||||
@ref = ActiveSupport::Dependencies.ref(@class_name)
|
||||
@klass = Devise.ref(@class_name)
|
||||
|
||||
@path = (options[:path] || name).to_s
|
||||
@path_prefix = options[:path_prefix]
|
||||
|
||||
mod = options[:module] || "devise"
|
||||
@controllers = Hash.new { |h,k| h[k] = "#{mod}/#{k}" }
|
||||
@controllers.merge!(options[:controllers] || {})
|
||||
|
||||
@path_names = Hash.new { |h,k| h[k] = k.to_s }
|
||||
@path_names.merge!(:registration => "")
|
||||
@path_names.merge!(options[:path_names] || {})
|
||||
|
||||
@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)
|
||||
default_used_route(options)
|
||||
default_used_helpers(options)
|
||||
end
|
||||
|
||||
# Return modules for the mapping.
|
||||
@@ -73,13 +78,17 @@ module Devise
|
||||
|
||||
# Gives the class the mapping points to.
|
||||
def to
|
||||
@ref.get
|
||||
@klass.get
|
||||
end
|
||||
|
||||
def strategies
|
||||
@strategies ||= STRATEGIES.values_at(*self.modules).compact.uniq.reverse
|
||||
end
|
||||
|
||||
def no_input_strategies
|
||||
self.strategies & Devise::NO_INPUT
|
||||
end
|
||||
|
||||
def routes
|
||||
@routes ||= ROUTES.values_at(*self.modules).compact.uniq
|
||||
end
|
||||
@@ -106,5 +115,62 @@ module Devise
|
||||
end
|
||||
METHOD
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def default_failure_app(options)
|
||||
@failure_app = options[:failure_app] || Devise::FailureApp
|
||||
if @failure_app.is_a?(String)
|
||||
ref = Devise.ref(@failure_app)
|
||||
@failure_app = lambda { |env| ref.get.call(env) }
|
||||
end
|
||||
end
|
||||
|
||||
def default_controllers(options)
|
||||
mod = options[:module] || "devise"
|
||||
@controllers = Hash.new { |h,k| h[k] = "#{mod}/#{k}" }
|
||||
@controllers.merge!(options[:controllers]) if options[:controllers]
|
||||
@controllers.each { |k,v| @controllers[k] = v.to_s }
|
||||
end
|
||||
|
||||
def default_path_names(options)
|
||||
@path_names = Hash.new { |h,k| h[k] = k.to_s }
|
||||
@path_names[:registration] = ""
|
||||
@path_names.merge!(options[:path_names]) if options[:path_names]
|
||||
end
|
||||
|
||||
def default_constraints(options)
|
||||
@constraints = Hash.new
|
||||
@constraints.merge!(options[:constraints]) if options[:constraints]
|
||||
end
|
||||
|
||||
def default_defaults(options)
|
||||
@defaults = Hash.new
|
||||
@defaults.merge!(options[:defaults]) if options[:defaults]
|
||||
end
|
||||
|
||||
def default_used_route(options)
|
||||
singularizer = lambda { |s| s.to_s.singularize.to_sym }
|
||||
|
||||
if options.has_key?(:only)
|
||||
@used_routes = self.routes & Array(options[:only]).map(&singularizer)
|
||||
elsif options[:skip] == :all
|
||||
@used_routes = []
|
||||
else
|
||||
@used_routes = self.routes - Array(options[:skip]).map(&singularizer)
|
||||
end
|
||||
end
|
||||
|
||||
def default_used_helpers(options)
|
||||
singularizer = lambda { |s| s.to_s.singularize.to_sym }
|
||||
|
||||
if options[:skip_helpers] == true
|
||||
@used_helpers = @used_routes
|
||||
elsif skip = options[:skip_helpers]
|
||||
@used_helpers = self.routes - Array(skip).map(&singularizer)
|
||||
else
|
||||
@used_helpers = self.routes
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
module Devise
|
||||
module Models
|
||||
class MissingAttribute < StandardError
|
||||
def initialize(attributes)
|
||||
@attributes = attributes
|
||||
end
|
||||
|
||||
def message
|
||||
"The following attribute(s) is (are) missing on your model: #{@attributes.join(", ")}"
|
||||
end
|
||||
end
|
||||
|
||||
# Creates configuration values for Devise and for the given module.
|
||||
#
|
||||
# Devise::Models.config(Devise::Authenticatable, :stretches, 10)
|
||||
@@ -17,6 +27,9 @@ module Devise
|
||||
# inside the given class.
|
||||
#
|
||||
def self.config(mod, *accessors) #:nodoc:
|
||||
class << mod; attr_accessor :available_configs; end
|
||||
mod.available_configs = accessors
|
||||
|
||||
accessors.each do |accessor|
|
||||
mod.class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
||||
def #{accessor}
|
||||
@@ -36,6 +49,23 @@ module Devise
|
||||
end
|
||||
end
|
||||
|
||||
def self.check_fields!(klass)
|
||||
failed_attributes = []
|
||||
instance = klass.new
|
||||
|
||||
klass.devise_modules.each do |mod|
|
||||
constant = const_get(mod.to_s.classify)
|
||||
|
||||
constant.required_fields(klass).each do |field|
|
||||
failed_attributes << field unless instance.respond_to?(field)
|
||||
end
|
||||
end
|
||||
|
||||
if failed_attributes.any?
|
||||
fail Devise::Models::MissingAttribute.new(failed_attributes)
|
||||
end
|
||||
end
|
||||
|
||||
# Include the chosen devise modules in your model:
|
||||
#
|
||||
# devise :database_authenticatable, :confirmable, :recoverable
|
||||
@@ -45,24 +75,45 @@ module Devise
|
||||
# for a complete description on those values.
|
||||
#
|
||||
def devise(*modules)
|
||||
include Devise::Models::Authenticatable
|
||||
options = modules.extract_options!
|
||||
self.devise_modules += modules.map(&:to_sym).uniq.sort_by { |s|
|
||||
options = modules.extract_options!.dup
|
||||
|
||||
selected_modules = modules.map(&:to_sym).uniq.sort_by do |s|
|
||||
Devise::ALL.index(s) || -1 # follow Devise::ALL order
|
||||
}
|
||||
end
|
||||
|
||||
devise_modules_hook! do
|
||||
devise_modules.each { |m| include Devise::Models.const_get(m.to_s.classify) }
|
||||
include Devise::Models::Authenticatable
|
||||
|
||||
selected_modules.each do |m|
|
||||
mod = Devise::Models.const_get(m.to_s.classify)
|
||||
|
||||
if mod.const_defined?("ClassMethods")
|
||||
class_mod = mod.const_get("ClassMethods")
|
||||
extend class_mod
|
||||
|
||||
if class_mod.respond_to?(:available_configs)
|
||||
available_configs = class_mod.available_configs
|
||||
available_configs.each do |config|
|
||||
next unless options.key?(config)
|
||||
send(:"#{config}=", options.delete(config))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
include mod
|
||||
end
|
||||
|
||||
self.devise_modules |= selected_modules
|
||||
options.each { |key, value| send(:"#{key}=", value) }
|
||||
end
|
||||
end
|
||||
|
||||
# The hook which is called inside devise. So your ORM can include devise
|
||||
# compatibility stuff.
|
||||
# The hook which is called inside devise.
|
||||
# So your ORM can include devise compatibility stuff.
|
||||
def devise_modules_hook!
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require 'devise/models/authenticatable'
|
||||
require 'devise/models/authenticatable'
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
require 'active_model/version'
|
||||
require 'devise/hooks/activatable'
|
||||
require 'devise/hooks/csrf_cleaner'
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
@@ -10,33 +12,39 @@ module Devise
|
||||
#
|
||||
# * +authentication_keys+: parameters used for authentication. By default [:email].
|
||||
#
|
||||
# * +http_authentication_key+: map the username passed via HTTP Auth to this parameter. Defaults to
|
||||
# the first element in +authentication_keys+.
|
||||
#
|
||||
# * +request_keys+: parameters from the request object used for authentication.
|
||||
# By specifying a symbol (which should be a request method), it will automatically be
|
||||
# passed to find_for_authentication method and considered in your model lookup.
|
||||
#
|
||||
# For instance, if you set :request_keys to [:subdomain], :subdomain will be considered
|
||||
# as key on authentication. This can also be a hash where the value is a boolean expliciting
|
||||
# as key on authentication. This can also be a hash where the value is a boolean specifying
|
||||
# if the value is required or not.
|
||||
#
|
||||
# * +http_authenticatable+: if this model allows http authentication. By default true.
|
||||
# * +http_authenticatable+: if this model allows http authentication. By default false.
|
||||
# It also accepts an array specifying the strategies that should allow http.
|
||||
#
|
||||
# * +params_authenticatable+: if this model allows authentication through request params. By default true.
|
||||
# It also accepts an array specifying the strategies that should allow params authentication.
|
||||
#
|
||||
# == Active?
|
||||
# * +skip_session_storage+: By default Devise will store the user in session.
|
||||
# By default is set to skip_session_storage: [:http_auth].
|
||||
#
|
||||
# Before authenticating a user and in each request, Devise checks if your model is active by
|
||||
# calling model.active?. This method is overwriten by other devise modules. For instance,
|
||||
# :confirmable overwrites .active? to only return true if your model was confirmed.
|
||||
# == active_for_authentication?
|
||||
#
|
||||
# You overwrite this method yourself, but if you do, don't forget to call super:
|
||||
# After authenticating a user and in each request, Devise checks if your model is active by
|
||||
# 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.
|
||||
#
|
||||
# def active?
|
||||
# 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?
|
||||
# end
|
||||
#
|
||||
# Whenever active? returns false, Devise asks the reason why your model is inactive using
|
||||
# Whenever active_for_authentication? returns false, Devise asks the reason why your model is inactive using
|
||||
# the inactive_message method. You can overwrite it as well:
|
||||
#
|
||||
# def inactive_message
|
||||
@@ -46,26 +54,38 @@ module Devise
|
||||
module Authenticatable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
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]
|
||||
|
||||
included do
|
||||
class_attribute :devise_modules, :instance_writer => false
|
||||
class_attribute :devise_modules, instance_writer: false
|
||||
self.devise_modules ||= []
|
||||
|
||||
before_validation :downcase_keys
|
||||
before_validation :strip_whitespace
|
||||
end
|
||||
|
||||
def self.required_fields(klass)
|
||||
[]
|
||||
end
|
||||
|
||||
# Check if the current object is valid for authentication. This method and
|
||||
# find_for_authentication are the methods used in a Warden::Strategy to check
|
||||
# if a model should be signed in or not.
|
||||
#
|
||||
# However, you should not overwrite this method, you should overwrite active? and
|
||||
# inactive_message instead.
|
||||
# However, you should not overwrite this method, you should overwrite active_for_authentication?
|
||||
# and inactive_message instead.
|
||||
def valid_for_authentication?
|
||||
if active?
|
||||
block_given? ? yield : true
|
||||
else
|
||||
inactive_message
|
||||
end
|
||||
block_given? ? yield : true
|
||||
end
|
||||
|
||||
def active?
|
||||
def unauthenticated_message
|
||||
:invalid
|
||||
end
|
||||
|
||||
def active_for_authentication?
|
||||
true
|
||||
end
|
||||
|
||||
@@ -76,8 +96,118 @@ module Devise
|
||||
def authenticatable_salt
|
||||
end
|
||||
|
||||
# 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[:except] = Array(options[:except])
|
||||
|
||||
if options[:force_except]
|
||||
options[:except].concat Array(options[:force_except])
|
||||
else
|
||||
options[:except].concat BLACKLIST_FOR_SERIALIZATION
|
||||
end
|
||||
|
||||
super(options)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def devise_mailer
|
||||
Devise.mailer
|
||||
end
|
||||
|
||||
# This is an internal method called every time Devise needs
|
||||
# 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
|
||||
# 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:
|
||||
#
|
||||
# class User
|
||||
# devise :database_authenticatable, :confirmable
|
||||
#
|
||||
# after_commit :send_pending_notifications
|
||||
#
|
||||
# protected
|
||||
#
|
||||
# def send_devise_notification(notification, *args)
|
||||
# # If the record is new or changed then delay the
|
||||
# # delivery until the after_commit callback otherwise
|
||||
# # send now because after_commit will not be called.
|
||||
# if new_record? || changed?
|
||||
# pending_notifications << [notification, args]
|
||||
# else
|
||||
# devise_mailer.send(notification, self, *args).deliver
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# def send_pending_notifications
|
||||
# pending_notifications.each do |notification, args|
|
||||
# devise_mailer.send(notification, self, *args).deliver
|
||||
# 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
|
||||
# end
|
||||
#
|
||||
# def pending_notifications
|
||||
# @pending_notifications ||= []
|
||||
# end
|
||||
# end
|
||||
#
|
||||
def send_devise_notification(notification, *args)
|
||||
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) }
|
||||
end
|
||||
|
||||
def strip_whitespace
|
||||
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] = 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
|
||||
# globally configured key.
|
||||
elsif respond_to?(attr) && respond_to?("#{attr}=")
|
||||
new_value = send(attr).try(method)
|
||||
send("#{attr}=", new_value)
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
Devise::Models.config(self, :authentication_keys, :request_keys, :case_insensitive_keys, :http_authenticatable, :params_authenticatable)
|
||||
Devise::Models.config(self, :authentication_keys, :request_keys, :strip_whitespace_keys,
|
||||
:case_insensitive_keys, :http_authenticatable, :params_authenticatable, :skip_session_storage,
|
||||
:http_authentication_key)
|
||||
|
||||
def serialize_into_session(record)
|
||||
[record.to_key, record.authenticatable_salt]
|
||||
end
|
||||
|
||||
def serialize_from_session(key, salt)
|
||||
record = to_adapter.get(key)
|
||||
record if record && record.authenticatable_salt == salt
|
||||
end
|
||||
|
||||
def params_authenticatable?(strategy)
|
||||
params_authenticatable.is_a?(Array) ?
|
||||
@@ -90,37 +220,46 @@ module Devise
|
||||
end
|
||||
|
||||
# Find first record based on conditions given (ie by the sign in form).
|
||||
# This method is always called during an authentication process but
|
||||
# it may be wrapped as well. For instance, database authenticatable
|
||||
# provides a `find_for_database_authentication` that wraps a call to
|
||||
# this method. This allows you to customize both database authenticatable
|
||||
# or the whole authenticate stack by customize `find_for_authentication.`
|
||||
#
|
||||
# Overwrite to add customized conditions, create a join, or maybe use a
|
||||
# namedscope to filter records while authenticating.
|
||||
# Example:
|
||||
#
|
||||
# def self.find_for_authentication(conditions={})
|
||||
# conditions[:active] = true
|
||||
# super
|
||||
# def self.find_for_authentication(tainted_conditions)
|
||||
# find_first_by_auth_conditions(tainted_conditions, active: true)
|
||||
# end
|
||||
#
|
||||
def find_for_authentication(conditions)
|
||||
filter_auth_params(conditions)
|
||||
case_insensitive_keys.each { |k| conditions[k].try(:downcase!) }
|
||||
to_adapter.find_first(conditions)
|
||||
# Finally, notice that Devise also queries for users in other scenarios
|
||||
# besides authentication, for example when retrieving an user to send
|
||||
# an e-mail for password reset. In such cases, find_for_authentication
|
||||
# is not called.
|
||||
def find_for_authentication(tainted_conditions)
|
||||
find_first_by_auth_conditions(tainted_conditions)
|
||||
end
|
||||
|
||||
# Find an initialize a record setting an error if it can't be found.
|
||||
def find_first_by_auth_conditions(tainted_conditions, opts={})
|
||||
to_adapter.find_first(devise_parameter_filter.filter(tainted_conditions).merge(opts))
|
||||
end
|
||||
|
||||
# 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:
|
||||
case_insensitive_keys.each { |k| attributes[k].try(:downcase!) }
|
||||
|
||||
attributes = attributes.slice(*required_attributes)
|
||||
attributes = attributes.slice(*required_attributes).with_indifferent_access
|
||||
attributes.delete_if { |key, value| value.blank? }
|
||||
|
||||
if attributes.size == required_attributes.size
|
||||
record = to_adapter.find_first(filter_auth_params(attributes))
|
||||
record = find_first_by_auth_conditions(attributes)
|
||||
end
|
||||
|
||||
|
||||
unless record
|
||||
record = new
|
||||
|
||||
@@ -136,21 +275,10 @@ module Devise
|
||||
|
||||
protected
|
||||
|
||||
# Force keys to be string to avoid injection on mongoid related database.
|
||||
def filter_auth_params(conditions)
|
||||
conditions.each do |k, v|
|
||||
conditions[k] = v.to_s
|
||||
end
|
||||
end
|
||||
|
||||
# Generate a token by looping and ensuring does not already exist.
|
||||
def generate_token(column)
|
||||
loop do
|
||||
token = Devise.friendly_token
|
||||
break token unless to_adapter.find_first({ column => token })
|
||||
end
|
||||
def devise_parameter_filter
|
||||
@devise_parameter_filter ||= Devise::ParameterFilter.new(case_insensitive_keys, strip_whitespace_keys)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,61 +5,136 @@ 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 - An OpenSSL::HMAC.hexdigest of @raw_confirmation_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_for:
|
||||
# Confirmable adds the following options to +devise+:
|
||||
#
|
||||
# * +confirm_within+: 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 confirm_within is zero, it means users always have to confirm to sign in.
|
||||
# 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
|
||||
# stored in unconfirmed email column, and copied to email column on successful
|
||||
# confirmation.
|
||||
# * +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.
|
||||
#
|
||||
# == 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_confirmation_instructions, :if => :confirmation_required?
|
||||
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?
|
||||
end
|
||||
|
||||
def initialize(*args, &block)
|
||||
@bypass_confirmation_postpone = false
|
||||
@reconfirmation_required = false
|
||||
@skip_confirmation_notification = false
|
||||
@raw_confirmation_token = nil
|
||||
super
|
||||
end
|
||||
|
||||
def self.required_fields(klass)
|
||||
required_methods = [:confirmation_token, :confirmed_at, :confirmation_sent_at]
|
||||
required_methods << :unconfirmed_email if klass.reconfirmable
|
||||
required_methods
|
||||
end
|
||||
|
||||
# Confirm a user by setting it's confirmed_at to actual time. If the user
|
||||
# is already confirmed, add en error to email field
|
||||
def confirm!
|
||||
unless_confirmed do
|
||||
self.confirmation_token = nil
|
||||
self.confirmed_at = Time.now
|
||||
save(:validate => false)
|
||||
# is already confirmed, add an error to email field. If the user is invalid
|
||||
# add errors
|
||||
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))
|
||||
return false
|
||||
end
|
||||
|
||||
self.confirmed_at = Time.now.utc
|
||||
|
||||
saved = if self.class.reconfirmable && unconfirmed_email.present?
|
||||
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)
|
||||
else
|
||||
save(validate: args[:ensure_valid] == true)
|
||||
end
|
||||
|
||||
after_confirmation if saved
|
||||
saved
|
||||
end
|
||||
end
|
||||
|
||||
def confirm!(args={})
|
||||
ActiveSupport::Deprecation.warn "confirm! is deprecated in favor of confirm"
|
||||
confirm(args)
|
||||
end
|
||||
|
||||
# Verifies whether a user is confirmed or not
|
||||
def confirmed?
|
||||
!!confirmed_at
|
||||
end
|
||||
|
||||
def pending_reconfirmation?
|
||||
self.class.reconfirmable && unconfirmed_email.present?
|
||||
end
|
||||
|
||||
# Send confirmation instructions by email
|
||||
def send_confirmation_instructions
|
||||
generate_confirmation_token! if self.confirmation_token.nil?
|
||||
::Devise.mailer.confirmation_instructions(self).deliver
|
||||
unless @raw_confirmation_token
|
||||
generate_confirmation_token!
|
||||
end
|
||||
|
||||
opts = pending_reconfirmation? ? { to: unconfirmed_email } : { }
|
||||
send_devise_notification(:confirmation_instructions, @raw_confirmation_token, opts)
|
||||
end
|
||||
|
||||
# Resend confirmation token. This method does not need to generate a new token.
|
||||
def resend_confirmation_token
|
||||
unless_confirmed { send_confirmation_instructions }
|
||||
def send_reconfirmation_instructions
|
||||
@reconfirmation_required = false
|
||||
|
||||
unless @skip_confirmation_notification
|
||||
send_confirmation_instructions
|
||||
end
|
||||
end
|
||||
|
||||
# Overwrites active? from Devise::Models::Activatable for confirmation
|
||||
# Resend confirmation token.
|
||||
# Regenerates the token if the period is expired.
|
||||
def resend_confirmation_instructions
|
||||
pending_any_confirmation do
|
||||
send_confirmation_instructions
|
||||
end
|
||||
end
|
||||
|
||||
# Overwrites active_for_authentication? for confirmation
|
||||
# by verifying whether a user is active to sign in or not. If the user
|
||||
# is already confirmed, it should never be blocked. Otherwise we need to
|
||||
# calculate if the confirm time has not expired for this user.
|
||||
def active?
|
||||
def active_for_authentication?
|
||||
super && (!confirmation_required? || confirmed? || confirmation_period_valid?)
|
||||
end
|
||||
|
||||
@@ -71,11 +146,30 @@ module Devise
|
||||
# If you don't want confirmation to be sent on create, neither a code
|
||||
# to be generated, call skip_confirmation!
|
||||
def skip_confirmation!
|
||||
self.confirmed_at = Time.now
|
||||
self.confirmed_at = Time.now.utc
|
||||
end
|
||||
|
||||
# Skips sending the confirmation/reconfirmation notification email after_create/after_update. Unlike
|
||||
# #skip_confirmation!, record still requires confirmation.
|
||||
def skip_confirmation_notification!
|
||||
@skip_confirmation_notification = true
|
||||
end
|
||||
|
||||
# If you don't want reconfirmation to be sent, neither a code
|
||||
# to be generated, call skip_reconfirmation!
|
||||
def skip_reconfirmation!
|
||||
@bypass_confirmation_postpone = true
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# A callback method used to deliver confirmation
|
||||
# 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
|
||||
end
|
||||
|
||||
# Callback to overwrite if confirmation is required or not.
|
||||
def confirmation_required?
|
||||
!confirmed?
|
||||
@@ -84,30 +178,48 @@ 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_in is a model configuration, must always be an integer value.
|
||||
# Confirm_within is a model configuration, must always be an integer value.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# # confirm_within = 1.day and confirmation_sent_at = today
|
||||
# # allow_unconfirmed_access_for = 1.day and confirmation_sent_at = today
|
||||
# confirmation_period_valid? # returns true
|
||||
#
|
||||
# # confirm_within = 5.days and confirmation_sent_at = 4.days.ago
|
||||
# # allow_unconfirmed_access_for = 5.days and confirmation_sent_at = 4.days.ago
|
||||
# confirmation_period_valid? # returns true
|
||||
#
|
||||
# # confirm_within = 5.days and confirmation_sent_at = 5.days.ago
|
||||
# # allow_unconfirmed_access_for = 5.days and confirmation_sent_at = 5.days.ago
|
||||
# confirmation_period_valid? # returns false
|
||||
#
|
||||
# # confirm_within = 0.days
|
||||
# # allow_unconfirmed_access_for = 0.days
|
||||
# confirmation_period_valid? # will always return false
|
||||
#
|
||||
# # allow_unconfirmed_access_for = nil
|
||||
# confirmation_period_valid? # will always return true
|
||||
#
|
||||
def confirmation_period_valid?
|
||||
confirmation_sent_at && confirmation_sent_at.utc >= self.class.confirm_within.ago
|
||||
self.class.allow_unconfirmed_access_for.nil? || (confirmation_sent_at && confirmation_sent_at.utc >= self.class.allow_unconfirmed_access_for.ago)
|
||||
end
|
||||
|
||||
# Checks whether the record is confirmed or not, yielding to the block
|
||||
# if it's already confirmed, otherwise adds an error to email.
|
||||
def unless_confirmed
|
||||
unless confirmed?
|
||||
# Checks if the user confirmation happens before the token becomes invalid
|
||||
# Examples:
|
||||
#
|
||||
# # confirm_within = 3.days and confirmation_sent_at = 2.days.ago
|
||||
# confirmation_period_expired? # returns false
|
||||
#
|
||||
# # confirm_within = 3.days and confirmation_sent_at = 4.days.ago
|
||||
# confirmation_period_expired? # returns true
|
||||
#
|
||||
# # confirm_within = nil
|
||||
# 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)
|
||||
end
|
||||
|
||||
# Checks whether the record requires any confirmation.
|
||||
def pending_any_confirmation
|
||||
if (!confirmed? || pending_reconfirmation?)
|
||||
yield
|
||||
else
|
||||
self.errors.add(:email, :already_confirmed)
|
||||
@@ -115,45 +227,90 @@ module Devise
|
||||
end
|
||||
end
|
||||
|
||||
# Generates a new random token for confirmation, and stores the time
|
||||
# this token is being generated
|
||||
# Generates a new random token for confirmation, and stores
|
||||
# the time this token is being generated in confirmation_sent_at
|
||||
def generate_confirmation_token
|
||||
self.confirmed_at = nil
|
||||
self.confirmation_token = self.class.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
|
||||
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
|
||||
end
|
||||
|
||||
def postpone_email_change?
|
||||
postpone = self.class.reconfirmable && email_changed? && !@bypass_confirmation_postpone && self.email.present?
|
||||
@bypass_confirmation_postpone = false
|
||||
postpone
|
||||
end
|
||||
|
||||
def reconfirmation_required?
|
||||
self.class.reconfirmable && @reconfirmation_required && self.email.present?
|
||||
end
|
||||
|
||||
def send_confirmation_notification?
|
||||
confirmation_required? && !@skip_confirmation_notification && self.email.present?
|
||||
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
|
||||
|
||||
module ClassMethods
|
||||
# Attempt to find a user by it's email. If a record is found, send new
|
||||
# confirmation instructions to it. If not user is found, returns a new user
|
||||
# with an email not found error.
|
||||
# Attempt to find a user by its email. If a record is found, send new
|
||||
# confirmation instructions to it. If not, try searching for a user by unconfirmed_email
|
||||
# field. If no user is found, returns a new user with an email not found error.
|
||||
# Options must contain the user email
|
||||
def send_confirmation_instructions(attributes={})
|
||||
confirmable = find_or_initialize_with_errors(confirmation_keys, attributes, :not_found)
|
||||
confirmable.resend_confirmation_token if confirmable.persisted?
|
||||
confirmable = find_by_unconfirmed_email_with_errors(attributes) if reconfirmable
|
||||
unless confirmable.try(:persisted?)
|
||||
confirmable = find_or_initialize_with_errors(confirmation_keys, attributes, :not_found)
|
||||
end
|
||||
confirmable.resend_confirmation_instructions if confirmable.persisted?
|
||||
confirmable
|
||||
end
|
||||
|
||||
# Find a user by it's confirmation token and try to confirm it.
|
||||
# Find a user by its confirmation token and try to confirm it.
|
||||
# If no user is found, returns a new user with an error.
|
||||
# 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)
|
||||
confirmable.confirm! if confirmable.persisted?
|
||||
confirmable.confirm if confirmable.persisted?
|
||||
confirmable.confirmation_token = original_token
|
||||
confirmable
|
||||
end
|
||||
|
||||
# Generate a token checking if one does not already exist in the database.
|
||||
def confirmation_token
|
||||
generate_token(:confirmation_token)
|
||||
# Find a record for confirmation by unconfirmed email field
|
||||
def find_by_unconfirmed_email_with_errors(attributes = {})
|
||||
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)
|
||||
find_or_initialize_with_errors(unconfirmed_required_attributes, unconfirmed_attributes, :not_found)
|
||||
end
|
||||
|
||||
Devise::Models.config(self, :confirm_within, :confirmation_keys)
|
||||
Devise::Models.config(self, :allow_unconfirmed_access_for, :confirmation_keys, :reconfirmable, :confirm_within)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
require 'devise/strategies/database_authenticatable'
|
||||
require 'bcrypt'
|
||||
require 'devise/encryptor'
|
||||
|
||||
module Devise
|
||||
def self.bcrypt(klass, password)
|
||||
ActiveSupport::Deprecation.warn "Devise.bcrypt is deprecated; use Devise::Encryptor.digest instead"
|
||||
Devise::Encryptor.digest(klass, password)
|
||||
end
|
||||
|
||||
module Models
|
||||
# Authenticatable Module, responsible for encrypting password and validating
|
||||
# authenticity of a user while signing in.
|
||||
@@ -10,6 +15,9 @@ module Devise
|
||||
#
|
||||
# DatabaseAuthenticable 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.
|
||||
#
|
||||
# * +stretches+: the cost given to bcrypt.
|
||||
#
|
||||
# == Examples
|
||||
@@ -22,7 +30,10 @@ module Devise
|
||||
included do
|
||||
attr_reader :password, :current_password
|
||||
attr_accessor :password_confirmation
|
||||
before_save :downcase_keys
|
||||
end
|
||||
|
||||
def self.required_fields(klass)
|
||||
[:encrypted_password] + klass.authentication_keys
|
||||
end
|
||||
|
||||
# Generates password encryption based on the given value.
|
||||
@@ -31,11 +42,9 @@ module Devise
|
||||
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)
|
||||
bcrypt = ::BCrypt::Password.new(self.encrypted_password)
|
||||
password = ::BCrypt::Engine.hash_secret("#{password}#{self.class.pepper}", bcrypt.salt)
|
||||
Devise.secure_compare(password, self.encrypted_password)
|
||||
Devise::Encryptor.compare(self.class, encrypted_password, password)
|
||||
end
|
||||
|
||||
# Set password and password confirmation to nil
|
||||
@@ -43,10 +52,14 @@ 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.
|
||||
def update_with_password(params={})
|
||||
# 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)
|
||||
current_password = params.delete(:current_password)
|
||||
|
||||
if params[:password].blank?
|
||||
@@ -55,10 +68,11 @@ module Devise
|
||||
end
|
||||
|
||||
result = if valid_password?(current_password)
|
||||
update_attributes(params)
|
||||
update_attributes(params, *options)
|
||||
else
|
||||
self.assign_attributes(params, *options)
|
||||
self.valid?
|
||||
self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)
|
||||
self.attributes = params
|
||||
false
|
||||
end
|
||||
|
||||
@@ -66,24 +80,69 @@ module Devise
|
||||
result
|
||||
end
|
||||
|
||||
# Updates record attributes without asking for the current password.
|
||||
# Never allows a change to the current password. If you are using this
|
||||
# method, you should probably override this method to protect other
|
||||
# attributes you would not like to be updated without a password.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# def update_without_password(params, *options)
|
||||
# params.delete(:email)
|
||||
# super(params)
|
||||
# end
|
||||
#
|
||||
def update_without_password(params, *options)
|
||||
params.delete(:password)
|
||||
params.delete(:password_confirmation)
|
||||
|
||||
result = update_attributes(params, *options)
|
||||
clean_up_passwords
|
||||
result
|
||||
end
|
||||
|
||||
# Destroy record when :current_password matches, otherwise returns
|
||||
# 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)
|
||||
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
|
||||
|
||||
# A reliable way to expose the salt regardless of the implementation.
|
||||
def authenticatable_salt
|
||||
self.encrypted_password[0,29] if self.encrypted_password
|
||||
encrypted_password[0,29] if encrypted_password
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Downcase case-insensitive keys
|
||||
def downcase_keys
|
||||
self.class.case_insensitive_keys.each { |k| self[k].try(:downcase!) }
|
||||
end
|
||||
|
||||
# Digests the password using bcrypt.
|
||||
# Digests the password using bcrypt. Custom encryption should override
|
||||
# this method to apply their own algorithm.
|
||||
#
|
||||
# See https://github.com/plataformatec/devise-encryptable for examples
|
||||
# of other encryption 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
|
||||
|
||||
module ClassMethods
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
require 'devise/strategies/database_authenticatable'
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
# Encryptable Module adds support to several encryptors.
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
# Encryptable adds the following options to devise_for:
|
||||
#
|
||||
# * +pepper+: a random string used to provide a more secure hash.
|
||||
#
|
||||
# * +encryptor+: the encryptor going to be used. By default is nil.
|
||||
#
|
||||
# == Examples
|
||||
#
|
||||
# User.find(1).valid_password?('password123') # returns true/false
|
||||
#
|
||||
module Encryptable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
attr_reader :password, :current_password
|
||||
attr_accessor :password_confirmation
|
||||
end
|
||||
|
||||
# Generates password salt.
|
||||
def password=(new_password)
|
||||
self.password_salt = self.class.password_salt if new_password.present?
|
||||
super
|
||||
end
|
||||
|
||||
def authenticatable_salt
|
||||
self.password_salt
|
||||
end
|
||||
|
||||
# Verifies whether an incoming_password (ie from sign in) is the user password.
|
||||
def valid_password?(incoming_password)
|
||||
Devise.secure_compare(password_digest(incoming_password), self.encrypted_password)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Digests the password using the configured encryptor.
|
||||
def password_digest(password)
|
||||
if self.password_salt.present?
|
||||
self.class.encryptor_class.digest(password, self.class.stretches, self.password_salt, self.class.pepper)
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
Devise::Models.config(self, :encryptor)
|
||||
|
||||
# Returns the class for the configured encryptor.
|
||||
def encryptor_class
|
||||
@encryptor_class ||= case encryptor
|
||||
when :bcrypt
|
||||
raise "In order to use bcrypt as encryptor, simply remove :encryptable from your devise model"
|
||||
when nil
|
||||
raise "You need to give an :encryptor as option in order to use :encryptable"
|
||||
else
|
||||
::Devise::Encryptors.const_get(encryptor.to_s.classify)
|
||||
end
|
||||
end
|
||||
|
||||
def password_salt
|
||||
self.encryptor_class.salt(self.stretches)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,15 +1,17 @@
|
||||
require "devise/hooks/lockable"
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
# Handles blocking a user access after a certain number of attempts.
|
||||
# Lockable accepts two different strategies to unlock a user after it's
|
||||
# blocked: email and time. The former will send an email to the user when
|
||||
# the lock happens, containing a link to unlock it's account. The second
|
||||
# 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.
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
# Lockable adds the following options to devise_for:
|
||||
# Lockable adds the following options to +devise+:
|
||||
#
|
||||
# * +maximum_attempts+: how many attempts should be accepted before blocking the user.
|
||||
# * +lock_strategy+: lock the user account by :failed_attempts or :none.
|
||||
@@ -20,46 +22,61 @@ 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"
|
||||
|
||||
# Lock a user setting it's locked_at to actual time.
|
||||
def lock_access!
|
||||
self.locked_at = Time.now
|
||||
def self.required_fields(klass)
|
||||
attributes = []
|
||||
attributes << :failed_attempts if klass.lock_strategy_enabled?(:failed_attempts)
|
||||
attributes << :locked_at if klass.unlock_strategy_enabled?(:time)
|
||||
attributes << :unlock_token if klass.unlock_strategy_enabled?(:email)
|
||||
|
||||
if unlock_strategy_enabled?(:email)
|
||||
generate_unlock_token
|
||||
send_unlock_instructions
|
||||
end
|
||||
|
||||
save(:validate => false)
|
||||
attributes
|
||||
end
|
||||
|
||||
# Unlock a user by cleaning locket_at and failed_attempts.
|
||||
# Lock a user setting its locked_at to actual time.
|
||||
# * +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) && opts.fetch(:send_instructions, true)
|
||||
send_unlock_instructions
|
||||
else
|
||||
save(validate: false)
|
||||
end
|
||||
end
|
||||
|
||||
# Unlock a user by cleaning locked_at and failed_attempts.
|
||||
def unlock_access!
|
||||
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.
|
||||
def access_locked?
|
||||
locked_at && !lock_expired?
|
||||
!!locked_at && !lock_expired?
|
||||
end
|
||||
|
||||
# Send unlock instructions by email
|
||||
def send_unlock_instructions
|
||||
::Devise.mailer.unlock_instructions(self).deliver
|
||||
raw, enc = Devise.token_generator.generate(self.class, :unlock_token)
|
||||
self.unlock_token = enc
|
||||
self.save(validate: false)
|
||||
send_devise_notification(:unlock_instructions, raw, {})
|
||||
raw
|
||||
end
|
||||
|
||||
# Resend the unlock instructions if the user is locked.
|
||||
def resend_unlock_token
|
||||
def resend_unlock_instructions
|
||||
if_access_locked { send_unlock_instructions }
|
||||
end
|
||||
|
||||
# Overwrites active? from Devise::Models::Activatable for locking purposes
|
||||
# Overwrites active_for_authentication? from Devise::Models::Activatable for locking purposes
|
||||
# by verifying whether a user is active to sign in or not based on locked?
|
||||
def active?
|
||||
def active_for_authentication?
|
||||
super && !access_locked?
|
||||
end
|
||||
|
||||
@@ -79,36 +96,42 @@ module Devise
|
||||
# if the user can login or not (wrong password, etc)
|
||||
unlock_access! if lock_expired?
|
||||
|
||||
case (result = super)
|
||||
when Symbol
|
||||
return result
|
||||
when TrueClass
|
||||
self.failed_attempts = 0
|
||||
save(:validate => false)
|
||||
when FalseClass
|
||||
# PostgreSQL uses nil as the default value for integer columns set to 0
|
||||
if super && !access_locked?
|
||||
true
|
||||
else
|
||||
self.failed_attempts ||= 0
|
||||
self.failed_attempts += 1
|
||||
if attempts_exceeded?
|
||||
lock_access!
|
||||
return :locked
|
||||
lock_access! unless access_locked?
|
||||
else
|
||||
save(:validate => false)
|
||||
save(validate: false)
|
||||
end
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
result
|
||||
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 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
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def attempts_exceeded?
|
||||
self.failed_attempts > self.class.maximum_attempts
|
||||
self.failed_attempts >= self.class.maximum_attempts
|
||||
end
|
||||
|
||||
# Generates unlock token
|
||||
def generate_unlock_token
|
||||
self.unlock_token = self.class.unlock_token
|
||||
def last_attempt?
|
||||
self.failed_attempts == self.class.maximum_attempts - 1
|
||||
end
|
||||
|
||||
# Tells if the lock is expired if :time unlock strategy is active
|
||||
@@ -126,29 +149,33 @@ module Devise
|
||||
if access_locked?
|
||||
yield
|
||||
else
|
||||
self.errors.add(:email, :not_locked)
|
||||
self.errors.add(Devise.unlock_keys.first, :not_locked)
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
# Attempt to find a user by it's email. If a record is found, send new
|
||||
# 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.
|
||||
# Options must contain the user email
|
||||
# Options must contain the user's unlock keys
|
||||
def send_unlock_instructions(attributes={})
|
||||
lockable = find_or_initialize_with_errors(unlock_keys, attributes, :not_found)
|
||||
lockable.resend_unlock_token if lockable.persisted?
|
||||
lockable
|
||||
lockable = find_or_initialize_with_errors(unlock_keys, attributes, :not_found)
|
||||
lockable.resend_unlock_instructions if lockable.persisted?
|
||||
lockable
|
||||
end
|
||||
|
||||
# Find a user by it's unlock token and try to unlock it.
|
||||
# Find a user by its unlock token and try to unlock it.
|
||||
# If no user is found, returns a new user with an error.
|
||||
# If the user is not locked, creates an error for the user
|
||||
# Options must have the unlock_token
|
||||
def unlock_access_by_token(unlock_token)
|
||||
original_token = unlock_token
|
||||
unlock_token = Devise.token_generator.digest(self, :unlock_token, unlock_token)
|
||||
|
||||
lockable = find_or_initialize_with_error_by(:unlock_token, unlock_token)
|
||||
lockable.unlock_access! if lockable.persisted?
|
||||
lockable.unlock_token = original_token
|
||||
lockable
|
||||
end
|
||||
|
||||
@@ -162,11 +189,7 @@ module Devise
|
||||
self.lock_strategy == strategy
|
||||
end
|
||||
|
||||
def unlock_token
|
||||
Devise.friendly_token
|
||||
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
|
||||
|
||||
@@ -8,16 +8,20 @@ module Devise
|
||||
#
|
||||
# Oauthable adds the following options to devise_for:
|
||||
#
|
||||
# * +omniauth_providers+: Which providers are avaialble to this model. It expects an array:
|
||||
# * +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
|
||||
|
||||
def self.required_fields(klass)
|
||||
[]
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
Devise::Models.config(self, :omniauth_providers)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
module Devise
|
||||
module Models
|
||||
|
||||
# Recoverable takes care of reseting the user password and send reset instructions.
|
||||
# Recoverable takes care of resetting the user password and send reset instructions.
|
||||
#
|
||||
# ==Options
|
||||
#
|
||||
# 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')
|
||||
# User.find(1).reset_password('password123', 'password123')
|
||||
#
|
||||
# # only resets the user password, without saving the record
|
||||
# user = User.find(1)
|
||||
@@ -24,67 +26,138 @@ module Devise
|
||||
module Recoverable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def self.required_fields(klass)
|
||||
[:reset_password_sent_at, :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)
|
||||
def reset_password(new_password, new_password_confirmation)
|
||||
self.password = new_password
|
||||
self.password_confirmation = new_password_confirmation
|
||||
clear_reset_password_token if valid?
|
||||
|
||||
if valid?
|
||||
clear_reset_password_token
|
||||
after_password_reset
|
||||
end
|
||||
|
||||
save
|
||||
end
|
||||
|
||||
# Resets reset password token and send reset password instructions by email
|
||||
def reset_password!(new_password, new_password_confirmation)
|
||||
ActiveSupport::Deprecation.warn "reset_password! is deprecated in favor of reset_password"
|
||||
reset_password(new_password, new_password_confirmation)
|
||||
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
|
||||
generate_reset_password_token!
|
||||
::Devise.mailer.reset_password_instructions(self).deliver
|
||||
token = set_reset_password_token
|
||||
send_reset_password_instructions_notification(token)
|
||||
|
||||
token
|
||||
end
|
||||
|
||||
# Checks if the reset password token sent is within the limit time.
|
||||
# We do this by calculating if the difference between today and the
|
||||
# sending date does not exceed the confirm in time configured.
|
||||
# Returns true if the resource is not responding to reset_password_sent_at at all.
|
||||
# reset_password_within is a model configuration, must always be an integer value.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# # reset_password_within = 1.day and reset_password_sent_at = today
|
||||
# reset_password_period_valid? # returns true
|
||||
#
|
||||
# # reset_password_within = 5.days and reset_password_sent_at = 4.days.ago
|
||||
# reset_password_period_valid? # returns true
|
||||
#
|
||||
# # reset_password_within = 5.days and reset_password_sent_at = 5.days.ago
|
||||
# reset_password_period_valid? # returns false
|
||||
#
|
||||
# # reset_password_within = 0.days
|
||||
# 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
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Generates a new random token for reset password
|
||||
def generate_reset_password_token
|
||||
self.reset_password_token = self.class.reset_password_token
|
||||
end
|
||||
|
||||
# Resets the reset password token with and save the record without
|
||||
# validating
|
||||
def generate_reset_password_token!
|
||||
generate_reset_password_token && save(:validate => false)
|
||||
end
|
||||
|
||||
# Removes reset_password token
|
||||
def clear_reset_password_token
|
||||
self.reset_password_token = nil
|
||||
self.reset_password_sent_at = nil
|
||||
end
|
||||
|
||||
# A callback initiated after password is successfully reset. This can
|
||||
# be used to insert your own logic that is only run after the user
|
||||
# successfully resets their password.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# def after_password_reset
|
||||
# self.update_attribute(:invite_code, nil)
|
||||
# end
|
||||
#
|
||||
def after_password_reset
|
||||
end
|
||||
|
||||
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
|
||||
self.save(validate: false)
|
||||
raw
|
||||
end
|
||||
|
||||
def send_reset_password_instructions_notification(token)
|
||||
send_devise_notification(:reset_password_instructions, token, {})
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
# Attempt to find a user by it's email. If a record is found, send new
|
||||
# password instructions to it. If not user is found, returns a new user
|
||||
# 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.
|
||||
# Attributes must contain the user email
|
||||
# Attributes must contain the user's email
|
||||
def send_reset_password_instructions(attributes={})
|
||||
recoverable = find_or_initialize_with_errors(reset_password_keys, attributes, :not_found)
|
||||
recoverable.send_reset_password_instructions if recoverable.persisted?
|
||||
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 it's reset_password_token to reset it's
|
||||
# password. If a user is found, reset it's password and automatically
|
||||
# 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
|
||||
# containing an error in reset_password_token attribute.
|
||||
# Attributes must contain reset_password_token, password and confirmation
|
||||
def reset_password_by_token(attributes={})
|
||||
recoverable = find_or_initialize_with_error_by(:reset_password_token, attributes[:reset_password_token])
|
||||
recoverable.reset_password!(attributes[:password], attributes[:password_confirmation]) if recoverable.persisted?
|
||||
original_token = attributes[:reset_password_token]
|
||||
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?
|
||||
if recoverable.reset_password_period_valid?
|
||||
recoverable.reset_password(attributes[:password], attributes[:password_confirmation])
|
||||
else
|
||||
recoverable.errors.add(:reset_password_token, :expired)
|
||||
end
|
||||
end
|
||||
|
||||
recoverable.reset_password_token = original_token if recoverable.reset_password_token.present?
|
||||
recoverable
|
||||
end
|
||||
|
||||
Devise::Models.config(self, :reset_password_keys)
|
||||
Devise::Models.config(self, :reset_password_keys, :reset_password_within, :sign_in_after_reset_password)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,6 +5,10 @@ module Devise
|
||||
module Registerable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def self.required_fields(klass)
|
||||
[]
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
# A convenience method that receives both parameters and session to
|
||||
# initialize a user. This can be used by OAuth, for example, to send
|
||||
|
||||
@@ -17,19 +17,14 @@ 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.
|
||||
#
|
||||
# * +remember_across_browsers+: if a valid remember token can be re-used
|
||||
# between multiple browsers. By default remember_across_browsers is true
|
||||
# and cannot be turned off if you are using password salt instead of remember
|
||||
# token.
|
||||
#
|
||||
# * +extend_remember_period+: if true, extends the user's remember period
|
||||
# when remembered via cookie. False by default.
|
||||
#
|
||||
# * +cookie_options+: configuration options passed to the created cookie.
|
||||
# * +rememberable_options+: configuration options passed to the created cookie.
|
||||
#
|
||||
# == Examples
|
||||
#
|
||||
@@ -46,20 +41,25 @@ module Devise
|
||||
|
||||
attr_accessor :remember_me, :extend_remember_period
|
||||
|
||||
# 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 respond_to?(:remember_token) && generate_remember_token?
|
||||
self.remember_created_at = Time.now.utc if generate_remember_timestamp?(extend_period)
|
||||
save(:validate => false)
|
||||
def self.required_fields(klass)
|
||||
[:remember_created_at]
|
||||
end
|
||||
|
||||
# Removes the remember token only if it exists, and save the record
|
||||
# without validations.
|
||||
# Generate a new remember token and save the record without validations
|
||||
# if remember expired (token is no longer valid) or extend_remember_period is true
|
||||
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?
|
||||
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_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.
|
||||
@@ -78,28 +78,40 @@ module Devise
|
||||
elsif respond_to?(:authenticatable_salt) && (salt = authenticatable_salt)
|
||||
salt
|
||||
else
|
||||
raise "The #{self.class.name} class does not respond to remember_token and " <<
|
||||
"authenticatable_salt returns nil. In order to use rememberable, you must " <<
|
||||
"add a remember_token field to your model or ensure a password is always set."
|
||||
raise "authenticable_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."
|
||||
end
|
||||
end
|
||||
|
||||
def cookie_options
|
||||
self.class.cookie_options
|
||||
def rememberable_options
|
||||
self.class.rememberable_options
|
||||
end
|
||||
|
||||
# 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
|
||||
|
||||
protected
|
||||
|
||||
# Generate a token unless remember_across_browsers is true and there is
|
||||
# an existing remember_token or the existing remember_token has expried.
|
||||
def generate_remember_token? #:nodoc:
|
||||
!(self.class.remember_across_browsers && remember_token) || remember_expired?
|
||||
respond_to?(:remember_token) && remember_expired?
|
||||
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?
|
||||
extend_period || remember_expired?
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
@@ -111,16 +123,19 @@ module Devise
|
||||
# Recreate the user based on the stored cookie
|
||||
def serialize_from_cookie(id, remember_token)
|
||||
record = to_adapter.get(id)
|
||||
record if record && record.rememberable_value == remember_token && !record.remember_expired?
|
||||
record if record && !record.remember_expired? &&
|
||||
Devise.secure_compare(record.rememberable_value, remember_token)
|
||||
end
|
||||
|
||||
# Generate a token checking if one does not already exist in the database.
|
||||
def remember_token
|
||||
generate_token(:remember_token)
|
||||
def remember_token #:nodoc:
|
||||
loop do
|
||||
token = Devise.friendly_token
|
||||
break token unless to_adapter.find_first({ remember_token: token })
|
||||
end
|
||||
end
|
||||
|
||||
Devise::Models.config(self, :remember_for, :remember_across_browsers,
|
||||
:extend_remember_period, :cookie_options)
|
||||
Devise::Models.config(self, :remember_for, :extend_remember_period, :rememberable_options, :expire_all_remember_me_on_sign_out)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,9 +2,9 @@ require 'devise/hooks/timeoutable'
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
# Timeoutable takes care of veryfing 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
|
||||
@@ -20,21 +20,27 @@ module Devise
|
||||
module Timeoutable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def self.required_fields(klass)
|
||||
[]
|
||||
end
|
||||
|
||||
# Checks whether the user session has expired based on configured time.
|
||||
def timedout?(last_access)
|
||||
return false if remember_exists_and_not_expired?
|
||||
|
||||
last_access && last_access <= self.class.timeout_in.ago
|
||||
!timeout_in.nil? && last_access && last_access <= timeout_in.ago
|
||||
end
|
||||
|
||||
|
||||
def timeout_in
|
||||
self.class.timeout_in
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
def remember_exists_and_not_expired?
|
||||
return false unless respond_to?(:remember_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,72 +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.
|
||||
#
|
||||
# == 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=...
|
||||
#
|
||||
# * +stateless_token+: By default, when you sign up with a token, Devise will store the user in session
|
||||
# as any other authentication strategy. You can set stateless_token to true to avoid this.
|
||||
#
|
||||
module TokenAuthenticatable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# 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
|
||||
|
||||
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
|
||||
generate_token(:authentication_token)
|
||||
end
|
||||
|
||||
::Devise::Models.config(self, :token_authentication_key, :stateless_token)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -5,14 +5,18 @@ module Devise
|
||||
# Track information about your user sign in. It tracks the following columns:
|
||||
#
|
||||
# * sign_in_count - Increased every time a sign in is made (by form, openid, oauth)
|
||||
# * current_sign_in_at - A tiemstamp updated when the user signs in
|
||||
# * current_sign_in_at - A timestamp updated when the user signs in
|
||||
# * last_sign_in_at - Holds the timestamp of the previous sign in
|
||||
# * current_sign_in_ip - The remote ip updated when the user sign in
|
||||
# * last_sign_in_at - Holds the remote ip of the previous sign in
|
||||
# * last_sign_in_ip - Holds the remote ip of the previous sign in
|
||||
#
|
||||
module Trackable
|
||||
def update_tracked_fields!(request)
|
||||
old_current, new_current = self.current_sign_in_at, Time.now
|
||||
def self.required_fields(klass)
|
||||
[: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)
|
||||
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
|
||||
|
||||
@@ -22,8 +26,11 @@ module Devise
|
||||
|
||||
self.sign_in_count ||= 0
|
||||
self.sign_in_count += 1
|
||||
end
|
||||
|
||||
save(:validate => false)
|
||||
def update_tracked_fields!(request)
|
||||
update_tracked_fields(request)
|
||||
save(validate: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ module Devise
|
||||
module Models
|
||||
# Validatable creates all needed validations for a user email and password.
|
||||
# It's optional, given you may want to create the validations by yourself.
|
||||
# Automatically validate if the email is present, unique and it's format is
|
||||
# Automatically validate if the email is present, unique and its format is
|
||||
# valid. Also tests presence of password, confirmation and length.
|
||||
#
|
||||
# == Options
|
||||
@@ -10,28 +10,29 @@ 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 6..20.
|
||||
# * +password_length+: a range expressing password length. Defaults to 8..72.
|
||||
#
|
||||
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)
|
||||
[]
|
||||
end
|
||||
|
||||
def self.included(base)
|
||||
base.extend ClassMethods
|
||||
assert_validations_api!(base)
|
||||
|
||||
base.class_eval do
|
||||
validates_presence_of :email, :if => :email_required?
|
||||
validates_uniqueness_of :email, :scope => authentication_keys[1..-1],
|
||||
:case_sensitive => case_insensitive_keys.exclude?(:email), :allow_blank => true
|
||||
validates_format_of :email, :with => email_regexp, :allow_blank => true
|
||||
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?
|
||||
|
||||
with_options :if => :password_required? do |v|
|
||||
v.validates_presence_of :password
|
||||
v.validates_confirmation_of :password
|
||||
v.validates_length_of :password, :within => password_length, :allow_blank => true
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,30 +1,28 @@
|
||||
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 }
|
||||
s.add_module :rememberable
|
||||
s.add_module :database_authenticatable, controller: :sessions, route: { session: routes }
|
||||
s.add_module :rememberable, no_input: true
|
||||
end
|
||||
|
||||
# Other authentications
|
||||
d.add_module :encryptable
|
||||
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,12 +1,13 @@
|
||||
begin
|
||||
require "omniauth/core"
|
||||
rescue LoadError => e
|
||||
warn "Could not load 'omniauth/core'. Please ensure you have the oa-core gem installed and listed in your Gemfile."
|
||||
require "omniauth"
|
||||
require "omniauth/version"
|
||||
rescue LoadError
|
||||
warn "Could not load 'omniauth'. Please ensure you have the omniauth gem >= 1.0.0 installed and listed in your Gemfile."
|
||||
raise
|
||||
end
|
||||
|
||||
unless OmniAuth.config.respond_to? :test_mode
|
||||
raise "You are using an old OmniAuth version, please ensure you have 0.2.0.beta version or later installed."
|
||||
unless OmniAuth::VERSION =~ /^1\./
|
||||
raise "You are using an old OmniAuth version, please ensure you have 1.0.0.pr2 version or later installed."
|
||||
end
|
||||
|
||||
# Clean up the default path_prefix. It will be automatically set by Devise.
|
||||
@@ -14,19 +15,14 @@ OmniAuth.config.path_prefix = nil
|
||||
|
||||
OmniAuth.config.on_failure = Proc.new do |env|
|
||||
env['devise.mapping'] = Devise::Mapping.find_by_path!(env['PATH_INFO'], :path)
|
||||
controller_klass = "#{env['devise.mapping'].controllers[:omniauth_callbacks].camelize}Controller"
|
||||
controller_klass.constantize.action(:failure).call(env)
|
||||
controller_name = ActiveSupport::Inflector.camelize(env['devise.mapping'].controllers[:omniauth_callbacks])
|
||||
controller_klass = ActiveSupport::Inflector.constantize("#{controller_name}Controller")
|
||||
controller_klass.action(:failure).call(env)
|
||||
end
|
||||
|
||||
module Devise
|
||||
module OmniAuth
|
||||
autoload :Config, "devise/omniauth/config"
|
||||
autoload :UrlHelpers, "devise/omniauth/url_helpers"
|
||||
autoload :TestHelpers, "devise/omniauth/test_helpers"
|
||||
|
||||
class << self
|
||||
delegate :short_circuit_authorizers!, :unshort_circuit_authorizers!,
|
||||
:test_mode!, :stub!, :reset_stubs!, :to => "Devise::OmniAuth::TestHelpers"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,30 +1,45 @@
|
||||
module Devise
|
||||
module OmniAuth
|
||||
class StrategyNotFound < NameError
|
||||
def initialize(strategy)
|
||||
@strategy = strategy
|
||||
super("Could not find a strategy with name `#{strategy}'. " \
|
||||
"Please ensure it is required or explicitly set it using the :strategy_class option.")
|
||||
end
|
||||
end
|
||||
|
||||
class Config
|
||||
attr_accessor :strategy
|
||||
attr_reader :args
|
||||
attr_reader :args, :options, :provider, :strategy_name
|
||||
|
||||
def initialize(provider, args)
|
||||
@provider = provider
|
||||
@args = args
|
||||
@strategy = nil
|
||||
@provider = provider
|
||||
@args = args
|
||||
@options = @args.last.is_a?(Hash) ? @args.last : {}
|
||||
@strategy = nil
|
||||
@strategy_name = options[:name] || @provider
|
||||
@strategy_class = options.delete(:strategy_class)
|
||||
end
|
||||
|
||||
def strategy_class
|
||||
::OmniAuth::Strategies.const_get("#{::OmniAuth::Utils.camelize(@provider.to_s)}")
|
||||
@strategy_class ||= find_strategy || autoload_strategy
|
||||
end
|
||||
|
||||
def check_if_allow_stubs!
|
||||
raise "OmniAuth strategy for #{@provider} does not allow stubs, only OAuth2 ones do." unless allow_stubs?
|
||||
def find_strategy
|
||||
::OmniAuth.strategies.find do |strategy_class|
|
||||
strategy_class.to_s =~ /#{::OmniAuth::Utils.camelize(strategy_name)}$/ ||
|
||||
strategy_class.default_options[:name] == strategy_name
|
||||
end
|
||||
end
|
||||
|
||||
def allow_stubs?
|
||||
defined?(::OmniAuth::Strategies::OAuth2) && strategy.is_a?(::OmniAuth::Strategies::OAuth2)
|
||||
end
|
||||
|
||||
def build_connection(&block)
|
||||
strategy.client.connection.build(&block)
|
||||
def autoload_strategy
|
||||
name = ::OmniAuth::Utils.camelize(provider.to_s)
|
||||
if ::OmniAuth::Strategies.const_defined?(name)
|
||||
::OmniAuth::Strategies.const_get(name)
|
||||
else
|
||||
raise StrategyNotFound, name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
module Devise
|
||||
module OmniAuth
|
||||
module TestHelpers
|
||||
DEPRECATION_MESSAGE = "Faraday changed the way mocks work in a way incompatible to Devise. Luckily, Omniauth now supports a new test mode, please use it in your tests instead: https://github.com/intridea/omniauth/wiki/Integration-Testing"
|
||||
|
||||
DeprecationError = Class.new(StandardError)
|
||||
|
||||
def self.stub!(*args)
|
||||
raise DeprecationError, DEPRECATION_MESSAGE
|
||||
end
|
||||
|
||||
def self.reset_stubs!(*args)
|
||||
raise DeprecationError, DEPRECATION_MESSAGE
|
||||
end
|
||||
|
||||
def self.test_mode!
|
||||
warn DEPRECATION_MESSAGE
|
||||
end
|
||||
|
||||
def self.short_circuit_authorizers!
|
||||
::OmniAuth.config.test_mode = true
|
||||
warn DEPRECATION_MESSAGE
|
||||
end
|
||||
|
||||
def self.unshort_circuit_authorizers!
|
||||
::OmniAuth.config.test_mode = false
|
||||
warn DEPRECATION_MESSAGE
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,31 +2,16 @@ module Devise
|
||||
module OmniAuth
|
||||
module UrlHelpers
|
||||
def self.define_helpers(mapping)
|
||||
return unless mapping.omniauthable?
|
||||
|
||||
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
|
||||
def #{mapping.name}_omniauth_authorize_path(provider, params = {})
|
||||
if Devise.omniauth_configs[provider.to_sym]
|
||||
script_name = request.env["SCRIPT_NAME"]
|
||||
|
||||
path = "\#{script_name}/#{mapping.path}/auth/\#{provider}\".squeeze("/")
|
||||
path << '?' + params.to_param if params.present?
|
||||
path
|
||||
else
|
||||
raise ArgumentError, "Could not find omniauth provider \#{provider.inspect}"
|
||||
end
|
||||
end
|
||||
URL_HELPERS
|
||||
end
|
||||
|
||||
def omniauth_authorize_path(resource_or_scope, *args)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
send("#{scope}_omniauth_authorize_path", *args)
|
||||
_devise_route_context.send("#{scope}_omniauth_authorize_path", *args)
|
||||
end
|
||||
|
||||
def omniauth_callback_path(resource_or_scope, *args)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
send("#{scope}_omniauth_callback_path", *args)
|
||||
_devise_route_context.send("#{scope}_omniauth_callback_path", *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,38 +1,3 @@
|
||||
require 'orm_adapter/adapters/active_record'
|
||||
|
||||
module Devise
|
||||
module Orm
|
||||
# This module contains some helpers and handle schema (migrations):
|
||||
#
|
||||
# create_table :accounts do |t|
|
||||
# t.database_authenticatable
|
||||
# t.confirmable
|
||||
# t.recoverable
|
||||
# t.rememberable
|
||||
# t.trackable
|
||||
# t.lockable
|
||||
# t.timestamps
|
||||
# end
|
||||
#
|
||||
# However this method does not add indexes. If you need them, here is the declaration:
|
||||
#
|
||||
# add_index "accounts", ["email"], :name => "email", :unique => true
|
||||
# add_index "accounts", ["confirmation_token"], :name => "confirmation_token", :unique => true
|
||||
# add_index "accounts", ["reset_password_token"], :name => "reset_password_token", :unique => true
|
||||
#
|
||||
module ActiveRecord
|
||||
module Schema
|
||||
include Devise::Schema
|
||||
|
||||
# Tell how to apply schema methods.
|
||||
def apply_devise_schema(name, type, options={})
|
||||
column name, type.to_s.downcase.to_sym, options
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ActiveRecord::Base.extend Devise::Models
|
||||
ActiveRecord::ConnectionAdapters::Table.send :include, Devise::Orm::ActiveRecord::Schema
|
||||
ActiveRecord::ConnectionAdapters::TableDefinition.send :include, Devise::Orm::ActiveRecord::Schema
|
||||
@@ -1,31 +1,3 @@
|
||||
require 'orm_adapter/adapters/mongoid'
|
||||
|
||||
module Devise
|
||||
module Orm
|
||||
module Mongoid
|
||||
module Hook
|
||||
def devise_modules_hook!
|
||||
extend Schema
|
||||
yield
|
||||
return unless Devise.apply_schema
|
||||
devise_modules.each { |m| send(m) if respond_to?(m, true) }
|
||||
end
|
||||
end
|
||||
|
||||
module Schema
|
||||
include Devise::Schema
|
||||
|
||||
# Tell how to apply schema methods
|
||||
def apply_devise_schema(name, type, options={})
|
||||
type = Time if type == DateTime
|
||||
field name, { :type => type }.merge!(options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Mongoid::Document::ClassMethods.class_eval do
|
||||
include Devise::Models
|
||||
include Devise::Orm::Mongoid::Hook
|
||||
end
|
||||
Mongoid::Document::ClassMethods.send :include, Devise::Models
|
||||
|
||||
40
lib/devise/parameter_filter.rb
Normal file
40
lib/devise/parameter_filter.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
module Devise
|
||||
class ParameterFilter
|
||||
def initialize(case_insensitive_keys, strip_whitespace_keys)
|
||||
@case_insensitive_keys = case_insensitive_keys || []
|
||||
@strip_whitespace_keys = strip_whitespace_keys || []
|
||||
end
|
||||
|
||||
def filter(conditions)
|
||||
conditions = stringify_params(conditions.dup)
|
||||
|
||||
conditions.merge!(filtered_hash_by_method_for_given_keys(conditions.dup, :downcase, @case_insensitive_keys))
|
||||
conditions.merge!(filtered_hash_by_method_for_given_keys(conditions.dup, :strip, @strip_whitespace_keys))
|
||||
|
||||
conditions
|
||||
end
|
||||
|
||||
def filtered_hash_by_method_for_given_keys(conditions, method, condition_keys)
|
||||
condition_keys.each do |k|
|
||||
value = conditions[k]
|
||||
conditions[k] = value.send(method) if value.respond_to?(method)
|
||||
end
|
||||
|
||||
conditions
|
||||
end
|
||||
|
||||
# Force keys to be string to avoid injection on mongoid related database.
|
||||
def stringify_params(conditions)
|
||||
return conditions unless conditions.is_a?(Hash)
|
||||
conditions.each do |k, v|
|
||||
conditions[k] = v.to_s if param_requires_string_conversion?(v)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def param_requires_string_conversion?(value)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
99
lib/devise/parameter_sanitizer.rb
Normal file
99
lib/devise/parameter_sanitizer.rb
Normal file
@@ -0,0 +1,99 @@
|
||||
module Devise
|
||||
class BaseSanitizer
|
||||
attr_reader :params, :resource_name, :resource_class
|
||||
|
||||
def initialize(resource_class, resource_name, params)
|
||||
@resource_class = resource_class
|
||||
@resource_name = resource_name
|
||||
@params = params
|
||||
@blocks = Hash.new
|
||||
end
|
||||
|
||||
def for(kind, &block)
|
||||
if block_given?
|
||||
@blocks[kind] = block
|
||||
else
|
||||
default_for(kind)
|
||||
end
|
||||
end
|
||||
|
||||
def sanitize(kind)
|
||||
if block = @blocks[kind]
|
||||
block.call(default_params)
|
||||
else
|
||||
default_sanitize(kind)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def default_for(kind)
|
||||
raise ArgumentError, "a block is expected in Devise base sanitizer"
|
||||
end
|
||||
|
||||
def default_sanitize(kind)
|
||||
default_params
|
||||
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
|
||||
permit self.for(:sign_in)
|
||||
end
|
||||
|
||||
def sign_up
|
||||
permit self.for(:sign_up)
|
||||
end
|
||||
|
||||
def account_update
|
||||
permit self.for(:account_update)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# TODO: We do need to flatten so it works with strong_parameters
|
||||
# gem. We should drop it once we move to Rails 4 only support.
|
||||
def permit(keys)
|
||||
default_params.permit(*Array(keys))
|
||||
end
|
||||
|
||||
# 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)
|
||||
else
|
||||
raise NotImplementedError, "Devise doesn't know how to sanitize parameters for #{kind}"
|
||||
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
|
||||
end
|
||||
|
||||
def auth_keys
|
||||
@auth_keys ||= @resource_class.authentication_keys.respond_to?(:keys) ?
|
||||
@resource_class.authentication_keys.keys : @resource_class.authentication_keys
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,18 +0,0 @@
|
||||
module Devise
|
||||
class PathChecker
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
def self.default_url_options(*args)
|
||||
ApplicationController.default_url_options(*args)
|
||||
end
|
||||
|
||||
def initialize(env, scope)
|
||||
@current_path = "/#{env["SCRIPT_NAME"]}/#{env["PATH_INFO"]}".squeeze("/")
|
||||
@scope = scope
|
||||
end
|
||||
|
||||
def signing_out?
|
||||
@current_path == send("destroy_#{@scope}_session_path")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -17,7 +17,7 @@ module Devise
|
||||
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,21 +29,27 @@ module Devise
|
||||
end
|
||||
end
|
||||
|
||||
initializer "devise.encryptor_check" do
|
||||
case Devise.encryptor
|
||||
when :bcrypt
|
||||
puts "[DEVISE] From version 1.2, there is no need to set your encryptor to bcrypt " <<
|
||||
"since encryptors are only enabled if you include :encryptable in your models. " <<
|
||||
"With this change, we can integrate better with bcrypt and get rid of the " <<
|
||||
"password_salt column (since bcrypt stores the salt with password). " <<
|
||||
"Please comment config.encryptor in your initializer to get rid of this warning."
|
||||
when nil
|
||||
# Nothing to say
|
||||
else
|
||||
puts "[DEVISE] You are using #{Devise.encryptor} as encryptor. From version 1.2, " <<
|
||||
"you need to explicitly add `devise :encryptable, :encryptor => :#{Devise.encryptor}` " <<
|
||||
"to your models and comment the current value in the config/initializers/devise.rb. " <<
|
||||
"You must also add t.encryptable to your existing migrations."
|
||||
initializer "devise.secret_key" do |app|
|
||||
if app.respond_to?(:secrets)
|
||||
Devise.secret_key ||= app.secrets.secret_key_base
|
||||
elsif app.config.respond_to?(:secret_key_base)
|
||||
Devise.secret_key ||= app.config.secret_key_base
|
||||
end
|
||||
|
||||
Devise.token_generator ||=
|
||||
if secret_key = Devise.secret_key
|
||||
Devise::TokenGenerator.new(
|
||||
Devise::CachingKeyGenerator.new(Devise::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
|
||||
|
||||
@@ -1,10 +1,28 @@
|
||||
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!
|
||||
finalize_without_devise!
|
||||
Devise.configure_warden!
|
||||
result = finalize_without_devise!
|
||||
|
||||
@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. " \
|
||||
"In this case, you probably want to set Devise.router_name = MOUNT_POINT, where " \
|
||||
"MOUNT_POINT is a symbol representing where this engine will be mounted at. For " \
|
||||
"now Devise will default the mount point to :main_app. You can explicitly set it" \
|
||||
" to :main_app as well in case you want to keep the current behavior."
|
||||
end
|
||||
|
||||
Devise.configure_warden!
|
||||
Devise.regenerate_helpers!
|
||||
true
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
alias_method_chain :finalize!, :devise
|
||||
end
|
||||
@@ -25,79 +43,118 @@ 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 GET /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 correctly find by the route name.
|
||||
# * class_name: setup 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 setup path name that will be used, as rails routes does.
|
||||
# The following route configuration would setup 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: 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.
|
||||
#
|
||||
# devise_for :users, :singular => :user
|
||||
# devise_for :users, singular: :user
|
||||
#
|
||||
# * :path_names => configure different path names to overwrite defaults :sign_in, :sign_out, :sign_up,
|
||||
# :password, :confirmation, :unlock.
|
||||
# * 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' }
|
||||
# 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" }
|
||||
#
|
||||
# * :sign_out_via => the HTTP method(s) accepted for the :sign_out action (default: :get),
|
||||
# * 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),
|
||||
# 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: [:post, :delete]
|
||||
#
|
||||
# You need to make sure that your sign_out controls trigger a request with a matching HTTP method.
|
||||
#
|
||||
# * :module => the namespace to find controlers. By default, devise will access devise/sessions,
|
||||
# devise/registrations and so on. If you want to namespace all at once, use module:
|
||||
# * 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
|
||||
# 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!, pusblisher_account_signed_in, etc.
|
||||
# devise_for :users, only: :sessions
|
||||
#
|
||||
# * :skip => tell which controller you want to skip routes from being created:
|
||||
# * 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 => :sessions
|
||||
# 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:
|
||||
#
|
||||
# devise_for :users, format: false
|
||||
#
|
||||
# * constraints: works the same as Rails' constraints
|
||||
#
|
||||
# * defaults: works the same as Rails' defaults
|
||||
#
|
||||
# * router_name: allows application level router name to be overwritten for the current scope
|
||||
#
|
||||
# ==== Scoping
|
||||
#
|
||||
@@ -107,26 +164,26 @@ module ActionDispatch::Routing
|
||||
# devise_for :users
|
||||
# end
|
||||
#
|
||||
# However, since Devise uses the request path to retrieve the current user, it has one caveats.
|
||||
# If you are using a dynamic segment, as below:
|
||||
# However, since Devise uses the request path to retrieve the current user,
|
||||
# this has one caveat: If you are using a dynamic segment, like so ...
|
||||
#
|
||||
# scope ":locale" do
|
||||
# devise_for :users
|
||||
# end
|
||||
#
|
||||
# You are required to configure default_url_options in your ApplicationController class level, so
|
||||
# Devise can pick it:
|
||||
# you are required to configure default_url_options in your
|
||||
# ApplicationController class, so Devise can pick it:
|
||||
#
|
||||
# class ApplicationController < ActionController::Base
|
||||
# def self.default_url_options
|
||||
# { :locale => I18n.locale }
|
||||
# { locale: I18n.locale }
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# ==== Adding custom actions to override controllers
|
||||
#
|
||||
# You can pass a block to devise_for that will add any routes defined in the block to Devise's
|
||||
# list of known actions. This is important if you add a custom action to a controller that
|
||||
#
|
||||
# You can pass a block to devise_for that will add any routes defined in the block to Devise's
|
||||
# list of known actions. This is important if you add a custom action to a controller that
|
||||
# overrides an out of the box Devise controller.
|
||||
# For example:
|
||||
#
|
||||
@@ -141,19 +198,25 @@ module ActionDispatch::Routing
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# In order to get Devise to recognize the deactivate action, your devise_for entry should look like this,
|
||||
# In order to get Devise to recognize the deactivate action, your devise_scope entry should look like this:
|
||||
#
|
||||
# devise_for :owners, :controllers => { :registrations => "registrations" } do
|
||||
# post "deactivate", :to => "registrations#deactivate", :as => "deactivate_registration"
|
||||
# devise_scope :owner do
|
||||
# post "deactivate", to: "registrations#deactivate", as: "deactivate_registration"
|
||||
# end
|
||||
#
|
||||
def devise_for(*resources)
|
||||
@devise_finalized = false
|
||||
raise_no_secret_key unless Devise.secret_key
|
||||
options = resources.extract_options!
|
||||
|
||||
options[:as] ||= @scope[:as] if @scope[:as].present?
|
||||
options[:module] ||= @scope[:module] if @scope[:module].present?
|
||||
options[:path_prefix] ||= @scope[:path] if @scope[:path].present?
|
||||
options[:path_names] = (@scope[:path_names] || {}).merge(options[:path_names] || {})
|
||||
options[:constraints] = (@scope[:constraints] || {}).merge(options[:constraints] || {})
|
||||
options[:defaults] = (@scope[:defaults] || {}).merge(options[:defaults] || {})
|
||||
options[:options] = @scope[:options] || {}
|
||||
options[:options][:format] = false if options[:format] == false
|
||||
|
||||
resources.map!(&:to_sym)
|
||||
|
||||
@@ -164,7 +227,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
|
||||
@@ -172,27 +235,83 @@ module ActionDispatch::Routing
|
||||
raise_no_devise_method_error!(mapping.class_name)
|
||||
end
|
||||
|
||||
routes = mapping.routes
|
||||
routes -= Array(options.delete(:skip)).map { |s| s.to_s.singularize.to_sym }
|
||||
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
|
||||
yield if block_given?
|
||||
with_devise_exclusive_scope mapping.fullpath, mapping.name do
|
||||
with_devise_exclusive_scope mapping.fullpath, mapping.name, options do
|
||||
routes.each { |mod| send("devise_#{mod}", mapping, mapping.controllers) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Allow you to add authentication request from the router:
|
||||
# Allow you to add authentication request from the router.
|
||||
# Takes an optional scope and block to provide constraints
|
||||
# on the model instance itself.
|
||||
#
|
||||
# authenticate(:user) do
|
||||
# authenticate do
|
||||
# resources :post
|
||||
# end
|
||||
#
|
||||
def authenticate(scope)
|
||||
# authenticate(:admin) do
|
||||
# resources :users
|
||||
# end
|
||||
#
|
||||
# authenticate :user, lambda {|u| u.role == "admin"} do
|
||||
# root to: "admin/dashboard#show", as: :user_root
|
||||
# end
|
||||
#
|
||||
def authenticate(scope=nil, block=nil)
|
||||
constraints_for(:authenticate!, scope, block) do
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
# Allow you to route based on whether a scope is authenticated. You
|
||||
# can optionally specify which scope and a block. The block accepts
|
||||
# a model and allows extra constraints to be done on the instance.
|
||||
#
|
||||
# authenticated :admin do
|
||||
# root to: 'admin/dashboard#show', as: :admin_root
|
||||
# end
|
||||
#
|
||||
# authenticated do
|
||||
# root to: 'dashboard#show', as: :authenticated_root
|
||||
# end
|
||||
#
|
||||
# authenticated :user, lambda {|u| u.role == "admin"} do
|
||||
# root to: "admin/dashboard#show", as: :user_root
|
||||
# end
|
||||
#
|
||||
# root to: 'landing#show'
|
||||
#
|
||||
def authenticated(scope=nil, block=nil)
|
||||
constraints_for(:authenticate?, scope, block) do
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
# Allow you to route based on whether a scope is *not* authenticated.
|
||||
# You can optionally specify which scope.
|
||||
#
|
||||
# unauthenticated do
|
||||
# as :user do
|
||||
# root to: 'devise/registrations#new'
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# root to: 'dashboard#show'
|
||||
#
|
||||
def unauthenticated(scope=nil)
|
||||
constraint = lambda do |request|
|
||||
request.env["warden"].authenticate!(:scope => scope)
|
||||
not request.env["warden"].authenticate? scope: scope
|
||||
end
|
||||
|
||||
constraints(constraint) do
|
||||
@@ -205,12 +324,23 @@ module ActionDispatch::Routing
|
||||
# to which controller it is targetted.
|
||||
#
|
||||
# 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
|
||||
# you try to access a devise controller without specifying a scope, it will
|
||||
# raise ActionNotFound error.
|
||||
#
|
||||
# Also be aware of that 'devise_scope' and 'as' use the singular form of the
|
||||
# noun where other devise route commands expect the plural form. This would be a
|
||||
# good and working example.
|
||||
#
|
||||
# devise_scope :user do
|
||||
# get "/some/route" => "some_devise_controller"
|
||||
# end
|
||||
# devise_for :users
|
||||
#
|
||||
# Notice and be aware of the differences above between :user and :users
|
||||
def devise_scope(scope)
|
||||
constraint = lambda do |request|
|
||||
request.env["devise.mapping"] = Devise.mappings[scope]
|
||||
@@ -226,66 +356,139 @@ 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]
|
||||
}
|
||||
|
||||
resource :registration, :except => :show, :path => mapping.path_names[:registration],
|
||||
:path_names => path_names, :controller => controllers[:registrations] do
|
||||
options = {
|
||||
only: [:new, :create, :edit, :update, :destroy],
|
||||
path: mapping.path_names[:registration],
|
||||
path_names: path_names,
|
||||
controller: controllers[:registrations]
|
||||
}
|
||||
|
||||
resource :registration, options do
|
||||
get :cancel
|
||||
end
|
||||
end
|
||||
|
||||
def devise_omniauth_callback(mapping, controllers) #:nodoc:
|
||||
path_prefix = "/#{mapping.path}/auth"
|
||||
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` and manually defining the routes. Here is an example:
|
||||
|
||||
match "/users/auth/:provider",
|
||||
constraints: { provider: /google|facebook/ },
|
||||
to: "devise/omniauth_callbacks#passthru",
|
||||
as: :omniauth_authorize,
|
||||
via: [:get, :post]
|
||||
|
||||
match "/users/auth/:action/callback",
|
||||
constraints: { action: /google|facebook/ },
|
||||
to: "devise/omniauth_callbacks#:action",
|
||||
as: :omniauth_callback,
|
||||
via: [:get, :post]
|
||||
ERROR
|
||||
end
|
||||
|
||||
path, @scope[:path] = @scope[:path], nil
|
||||
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))
|
||||
|
||||
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]}#:action",
|
||||
as: :omniauth_callback,
|
||||
via: [:get, :post]
|
||||
ensure
|
||||
@scope[:path] = path
|
||||
end
|
||||
|
||||
def with_devise_exclusive_scope(new_path, new_as, options) #:nodoc:
|
||||
current_scope = @scope.dup
|
||||
|
||||
exclusive = { as: new_as, path: new_path, module: nil }
|
||||
exclusive.merge!(options.slice(:constraints, :defaults, :options))
|
||||
|
||||
exclusive.each_pair { |key, value| @scope[key] = value }
|
||||
yield
|
||||
ensure
|
||||
@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) &&
|
||||
(block.nil? || block.call(request.env["warden"].user(scope)))
|
||||
end
|
||||
|
||||
constraints(constraint) do
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
def set_omniauth_path_prefix!(path_prefix) #:nodoc:
|
||||
if ::OmniAuth.config.path_prefix && ::OmniAuth.config.path_prefix != path_prefix
|
||||
warn "[DEVISE] You can only add :omniauthable behavior to one model."
|
||||
raise "Wrong OmniAuth configuration. If you are getting this exception, it means that either:\n\n" \
|
||||
"1) You are manually setting OmniAuth.config.path_prefix and it doesn't match the Devise one\n" \
|
||||
"2) You are setting :omniauthable in more than one model\n" \
|
||||
"3) You changed your Devise routes/OmniAuth setting and haven't restarted your server"
|
||||
else
|
||||
::OmniAuth.config.path_prefix = path_prefix
|
||||
end
|
||||
|
||||
match "/auth/:action/callback", :action => Regexp.union(mapping.to.omniauth_providers.map(&:to_s)),
|
||||
:to => controllers[:omniauth_callbacks], :as => :omniauth_callback
|
||||
end
|
||||
|
||||
def with_devise_exclusive_scope(new_path, new_as) #:nodoc:
|
||||
old_as, old_path, old_module = @scope[:as], @scope[:path], @scope[:module]
|
||||
@scope[:as], @scope[:path], @scope[:module] = new_as, new_path, nil
|
||||
yield
|
||||
ensure
|
||||
@scope[:as], @scope[:path], @scope[:module] = old_as, old_path, old_module
|
||||
def raise_no_secret_key #:nodoc:
|
||||
raise <<-ERROR
|
||||
Devise.secret_key was not set. Please add the following to your Devise initializer:
|
||||
|
||||
config.secret_key = '#{SecureRandom.hex(64)}'
|
||||
|
||||
Please ensure you restarted your application after installing Devise or setting the key.
|
||||
ERROR
|
||||
end
|
||||
|
||||
def raise_no_devise_method_error!(klass) #:nodoc:
|
||||
raise "#{klass} does not respond to 'devise' method. This usually means you haven't " <<
|
||||
"loaded your ORM file or it's being loaded too late. To fix it, be sure to require 'devise/orm/YOUR_ORM' " <<
|
||||
raise "#{klass} does not respond to 'devise' method. This usually means you haven't " \
|
||||
"loaded your ORM file or it's being loaded too late. To fix it, be sure to require 'devise/orm/YOUR_ORM' " \
|
||||
"inside 'config/initializers/devise.rb' or before your application definition in 'config/application.rb'"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,123 +3,20 @@ module Warden::Mixins::Common
|
||||
@request ||= ActionDispatch::Request.new(env)
|
||||
end
|
||||
|
||||
# This is called internally by Warden on logout
|
||||
# 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!
|
||||
request.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
|
||||
end
|
||||
|
||||
def cookies
|
||||
request.cookie_jar
|
||||
end
|
||||
end
|
||||
|
||||
class Warden::SessionSerializer
|
||||
def serialize(record)
|
||||
[record.class.name, record.to_key, record.authenticatable_salt]
|
||||
end
|
||||
|
||||
def deserialize(keys)
|
||||
if keys.size == 2
|
||||
raise "Devise changed how it stores objects in session. If you are seeing this message, " <<
|
||||
"you can fix it by changing one character in your cookie secret or cleaning up your " <<
|
||||
"database sessions if you are using a db store."
|
||||
end
|
||||
|
||||
klass, id, salt = keys
|
||||
|
||||
begin
|
||||
record = klass.constantize.to_adapter.get(id)
|
||||
record if record && record.authenticatable_salt == salt
|
||||
rescue NameError => e
|
||||
if e.message =~ /uninitialized constant/
|
||||
Rails.logger.debug "[Devise] Trying to deserialize invalid class #{klass}"
|
||||
nil
|
||||
else
|
||||
raise
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless Devise.rack_session?
|
||||
# We cannot use Rails Indifferent Hash because it messes up the flash object.
|
||||
class Devise::IndifferentHash < Hash
|
||||
alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
|
||||
alias_method :regular_update, :update unless method_defined?(:regular_update)
|
||||
|
||||
def [](key)
|
||||
super(convert_key(key))
|
||||
end
|
||||
|
||||
def []=(key, value)
|
||||
regular_writer(convert_key(key), value)
|
||||
end
|
||||
|
||||
alias_method :store, :[]=
|
||||
|
||||
def update(other_hash)
|
||||
other_hash.each_pair { |key, value| regular_writer(convert_key(key), value) }
|
||||
self
|
||||
end
|
||||
|
||||
alias_method :merge!, :update
|
||||
|
||||
def key?(key)
|
||||
super(convert_key(key))
|
||||
end
|
||||
|
||||
alias_method :include?, :key?
|
||||
alias_method :has_key?, :key?
|
||||
alias_method :member?, :key?
|
||||
|
||||
def fetch(key, *extras)
|
||||
super(convert_key(key), *extras)
|
||||
end
|
||||
|
||||
def values_at(*indices)
|
||||
indices.collect {|key| self[convert_key(key)]}
|
||||
end
|
||||
|
||||
def merge(hash)
|
||||
self.dup.update(hash)
|
||||
end
|
||||
|
||||
def delete(key)
|
||||
super(convert_key(key))
|
||||
end
|
||||
|
||||
def stringify_keys!; self end
|
||||
def stringify_keys; dup end
|
||||
|
||||
undef :symbolize_keys!
|
||||
def symbolize_keys; to_hash.symbolize_keys end
|
||||
|
||||
def to_options!; self end
|
||||
def to_hash; Hash.new.update(self) end
|
||||
|
||||
protected
|
||||
|
||||
def convert_key(key)
|
||||
key.kind_of?(Symbol) ? key.to_s : key
|
||||
end
|
||||
end
|
||||
|
||||
class ActionDispatch::Request
|
||||
def reset_session
|
||||
session.destroy if session && session.respond_to?(:destroy)
|
||||
self.session = {}
|
||||
@env['action_dispatch.request.flash_hash'] = nil
|
||||
end
|
||||
end
|
||||
|
||||
Warden::Manager.after_set_user :event => [:set_user, :authentication] do |record, warden, options|
|
||||
if options[:scope] && warden.authenticated?(options[:scope])
|
||||
request, flash = warden.request, warden.env['action_dispatch.request.flash_hash']
|
||||
backup = request.session.to_hash
|
||||
backup.delete("session_id")
|
||||
request.reset_session
|
||||
warden.env['action_dispatch.request.flash_hash'] = flash
|
||||
request.session = Devise::IndifferentHash.new.update(backup)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,97 +0,0 @@
|
||||
module Devise
|
||||
# Holds devise schema information. To use it, just include its methods
|
||||
# and overwrite the apply_schema method.
|
||||
module Schema
|
||||
|
||||
# Creates email when enabled (on by default), encrypted_password and password_salt.
|
||||
#
|
||||
# == Options
|
||||
# * :null - When true, allow columns to be null.
|
||||
# * :default - Should be set to "" when :null is false.
|
||||
#
|
||||
# == Notes
|
||||
# For Datamapper compatibility, we explicitly hardcode the limit for the
|
||||
# encrypter password field in 128 characters.
|
||||
def database_authenticatable(options={})
|
||||
null = options[:null] || false
|
||||
default = options.key?(:default) ? options[:default] : ("" if null == false)
|
||||
include_email = !self.respond_to?(:authentication_keys) || self.authentication_keys.include?(:email)
|
||||
|
||||
apply_devise_schema :email, String, :null => null, :default => default if include_email
|
||||
apply_devise_schema :encrypted_password, String, :null => null, :default => default, :limit => 128
|
||||
end
|
||||
|
||||
# Creates password salt for encryption support.
|
||||
def encryptable
|
||||
apply_devise_schema :password_salt, String
|
||||
end
|
||||
|
||||
# Creates authentication_token.
|
||||
def token_authenticatable
|
||||
apply_devise_schema :authentication_token, String
|
||||
end
|
||||
|
||||
# Creates confirmation_token, confirmed_at and confirmation_sent_at.
|
||||
def confirmable
|
||||
apply_devise_schema :confirmation_token, String
|
||||
apply_devise_schema :confirmed_at, DateTime
|
||||
apply_devise_schema :confirmation_sent_at, DateTime
|
||||
end
|
||||
|
||||
# Creates reset_password_token.
|
||||
def recoverable
|
||||
apply_devise_schema :reset_password_token, String
|
||||
end
|
||||
|
||||
# Creates remember_token and remember_created_at.
|
||||
#
|
||||
# == Options
|
||||
# * :use_salt - When true, does not create a remember_token and use password_salt instead.
|
||||
def rememberable(options={})
|
||||
use_salt = options.fetch(:use_salt, Devise.use_salt_as_remember_token)
|
||||
apply_devise_schema :remember_token, String unless use_salt
|
||||
apply_devise_schema :remember_created_at, DateTime
|
||||
end
|
||||
|
||||
# Creates sign_in_count, current_sign_in_at, last_sign_in_at,
|
||||
# current_sign_in_ip, last_sign_in_ip.
|
||||
def trackable
|
||||
apply_devise_schema :sign_in_count, Integer, :default => 0
|
||||
apply_devise_schema :current_sign_in_at, DateTime
|
||||
apply_devise_schema :last_sign_in_at, DateTime
|
||||
apply_devise_schema :current_sign_in_ip, String
|
||||
apply_devise_schema :last_sign_in_ip, String
|
||||
end
|
||||
|
||||
# Creates failed_attempts, unlock_token and locked_at depending on the options given.
|
||||
#
|
||||
# == Options
|
||||
# * :unlock_strategy - The strategy used for unlock. Can be :time, :email, :both (default), :none.
|
||||
# If :email or :both, creates a unlock_token field.
|
||||
# * :lock_strategy - The strategy used for locking. Can be :failed_attempts (default) or :none.
|
||||
def lockable(options={})
|
||||
unlock_strategy = options[:unlock_strategy]
|
||||
unlock_strategy ||= self.unlock_strategy if respond_to?(:unlock_strategy)
|
||||
unlock_strategy ||= :both
|
||||
|
||||
lock_strategy = options[:lock_strategy]
|
||||
lock_strategy ||= self.lock_strategy if respond_to?(:lock_strategy)
|
||||
lock_strategy ||= :failed_attempts
|
||||
|
||||
if lock_strategy == :failed_attempts
|
||||
apply_devise_schema :failed_attempts, Integer, :default => 0
|
||||
end
|
||||
|
||||
if [:both, :email].include?(unlock_strategy)
|
||||
apply_devise_schema :unlock_token, String
|
||||
end
|
||||
|
||||
apply_devise_schema :locked_at, DateTime
|
||||
end
|
||||
|
||||
# Overwrite with specific modification to create your own schema.
|
||||
def apply_devise_schema(name, type, options={})
|
||||
raise NotImplementedError
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -6,32 +6,47 @@ module Devise
|
||||
# parameters both from params or from http authorization headers. See database_authenticatable
|
||||
# for an example.
|
||||
class Authenticatable < Base
|
||||
attr_accessor :authentication_hash, :password
|
||||
attr_accessor :authentication_hash, :authentication_type, :password
|
||||
|
||||
def store?
|
||||
super && !mapping.to.skip_session_storage.include?(authentication_type)
|
||||
end
|
||||
|
||||
def valid?
|
||||
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
|
||||
|
||||
# Simply invokes valid_for_authentication? with the given block and deal with the result.
|
||||
# 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?
|
||||
# for more information.
|
||||
#
|
||||
# In case the resource can't be validated, it will fail with the given
|
||||
# unauthenticated_message.
|
||||
def validate(resource, &block)
|
||||
result = resource && resource.valid_for_authentication?(&block)
|
||||
|
||||
case result
|
||||
when String, Symbol
|
||||
fail!(result)
|
||||
false
|
||||
when TrueClass
|
||||
decorate(resource)
|
||||
if result
|
||||
true
|
||||
else
|
||||
result
|
||||
if resource
|
||||
fail!(resource.unauthenticated_message)
|
||||
end
|
||||
false
|
||||
end
|
||||
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
|
||||
|
||||
@@ -40,17 +55,17 @@ 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;
|
||||
#
|
||||
def valid_for_http_auth?
|
||||
http_authenticatable? && request.authorization && with_authentication_hash(http_auth_hash)
|
||||
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;
|
||||
@@ -58,8 +73,8 @@ module Devise
|
||||
# * If all authentication keys are present;
|
||||
#
|
||||
def valid_for_params_auth?
|
||||
params_authenticatable? && valid_request? &&
|
||||
valid_params? && with_authentication_hash(params_auth_hash)
|
||||
params_authenticatable? && valid_params_request? &&
|
||||
valid_params? && with_authentication_hash(:params_auth, params_auth_hash)
|
||||
end
|
||||
|
||||
# Check if the model accepts this strategy as http authenticatable.
|
||||
@@ -74,28 +89,18 @@ module Devise
|
||||
|
||||
# Extract the appropriate subhash for authentication from params.
|
||||
def params_auth_hash
|
||||
params[scope]
|
||||
end
|
||||
params[scope]
|
||||
end
|
||||
|
||||
# Extract a hash with attributes:values from the http params.
|
||||
def http_auth_hash
|
||||
keys = [authentication_keys.first, :password]
|
||||
keys = [http_authentication_key, :password]
|
||||
Hash[*keys.zip(decode_credentials).flatten]
|
||||
end
|
||||
|
||||
# By default, a request is valid if the controller is allowed and the VERB is POST.
|
||||
def valid_request?
|
||||
valid_controller? && valid_verb?
|
||||
end
|
||||
|
||||
# Check if the controller is the one registered for authentication.
|
||||
def valid_controller?
|
||||
mapping.controllers[:sessions] == params[:controller]
|
||||
end
|
||||
|
||||
# Check if it was a POST request.
|
||||
def valid_verb?
|
||||
request.post?
|
||||
# By default, a request is valid if the controller set the proper env variable.
|
||||
def valid_params_request?
|
||||
!!env["devise.allow_params_authentication"]
|
||||
end
|
||||
|
||||
# If the request is valid, finally check if params_auth_hash returns a hash.
|
||||
@@ -103,44 +108,50 @@ 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
|
||||
ActiveSupport::Base64.decode64($1).split(/:/, 2)
|
||||
Base64.decode64($1).split(/:/, 2)
|
||||
end
|
||||
|
||||
# Sets the authentication hash and the password from params_auth_hash or http_auth_hash.
|
||||
def with_authentication_hash(auth_values)
|
||||
self.authentication_hash = {}
|
||||
def with_authentication_hash(auth_type, auth_values)
|
||||
self.authentication_hash, self.authentication_type = {}, auth_type
|
||||
self.password = auth_values[:password]
|
||||
|
||||
parse_authentication_key_values(auth_values, authentication_keys) &&
|
||||
parse_authentication_key_values(request_values, request_keys)
|
||||
end
|
||||
|
||||
# Holds the authentication keys.
|
||||
def authentication_keys
|
||||
@authentication_keys ||= mapping.to.authentication_keys
|
||||
end
|
||||
|
||||
# Holds request keys.
|
||||
def http_authentication_key
|
||||
@http_authentication_key ||= mapping.to.http_authentication_key || case authentication_keys
|
||||
when Array then authentication_keys.first
|
||||
when Hash then authentication_keys.keys.first
|
||||
end
|
||||
end
|
||||
|
||||
def request_keys
|
||||
@request_keys ||= mapping.to.request_keys
|
||||
end
|
||||
|
||||
# Returns values from the request object.
|
||||
def request_values
|
||||
keys = request_keys.respond_to?(:keys) ? request_keys.keys : request_keys
|
||||
values = keys.map { |k| self.request.send(k) }
|
||||
Hash[keys.zip(values)]
|
||||
end
|
||||
|
||||
# Parse authentication keys considering if they should be enforced or not.
|
||||
def parse_authentication_key_values(hash, keys)
|
||||
keys.each do |key, enforce|
|
||||
value = hash[key].presence
|
||||
@@ -157,8 +168,9 @@ module Devise
|
||||
# becomes simply :database.
|
||||
def authenticatable_name
|
||||
@authenticatable_name ||=
|
||||
self.class.name.split("::").last.underscore.sub("_authenticatable", "").to_sym
|
||||
ActiveSupport::Inflector.underscore(self.class.name.split("::").last).
|
||||
sub("_authenticatable", "").to_sym
|
||||
end
|
||||
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