From 99b5bd1ca9d5c3e0d4a567555acc0426573198dc Mon Sep 17 00:00:00 2001 From: kououken Date: Mon, 4 Feb 2019 18:29:05 -0800 Subject: [PATCH 1/5] Configure registration app --- back/Pipfile | 3 ++- back/reimbursinator/settings.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/back/Pipfile b/back/Pipfile index 54943ec..c996bfc 100644 --- a/back/Pipfile +++ b/back/Pipfile @@ -9,8 +9,9 @@ verify_ssl = true django = "==2.1.5" django-cors-headers = "==2.4.0" djangorestframework = "==3.8.2" -gunicorn = "==19.6.0" django-rest-auth = "==0.9.3" +django-allauth = "==0.37.1" +gunicorn = "==19.6.0" [requires] python_version = "3.5" diff --git a/back/reimbursinator/settings.py b/back/reimbursinator/settings.py index 6fb5556..503958c 100644 --- a/back/reimbursinator/settings.py +++ b/back/reimbursinator/settings.py @@ -39,10 +39,14 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'django.contrib.sites', # 3rd party 'rest_framework', 'rest_framework.authtoken', + 'allauth', + 'allauth.account', 'rest_auth', + 'rest_auth.registration', 'corsheaders', # local 'users', @@ -149,3 +153,9 @@ USE_TZ = True # https://docs.djangoproject.com/en/2.1/howto/static-files/ STATIC_URL = '/static/' + +# Email Config + +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + +SITE_ID = 1 From 72ab00dd503277ed4d93ada26ca3a17ff88e988c Mon Sep 17 00:00:00 2001 From: kououken Date: Tue, 5 Feb 2019 14:56:48 -0800 Subject: [PATCH 2/5] User registration endpoint working. --- back/Pipfile.lock | 72 +++++++++++++++++++++++++++++++++++- back/db.sqlite3 | Bin 59392 -> 71680 bytes back/reimbursinator/urls.py | 1 + 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/back/Pipfile.lock b/back/Pipfile.lock index e493330..a6ed173 100644 --- a/back/Pipfile.lock +++ b/back/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "d3bf402a934e168cbdc04022effcdb9ff8d4fde5b83d79bb388ad2a4c547894a" + "sha256": "b1fc6b06ec8daa4efd9573865bc6c1732ae9354309e036bfe3ce0ab76b1a3bcd" }, "pipfile-spec": 6, "requires": { @@ -16,6 +16,27 @@ ] }, "default": { + "certifi": { + "hashes": [ + "sha256:47f9c83ef4c0c621eaef743f133f09fa8a74a9b75f037e8624f83bd1b6626cb7", + "sha256:993f830721089fef441cdfeb4b2c8c9df86f0c63239f06bd025a76a7daddb033" + ], + "version": "==2018.11.29" + }, + "chardet": { + "hashes": [ + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" + ], + "version": "==3.0.4" + }, + "defusedxml": { + "hashes": [ + "sha256:24d7f2f94f7f3cb6061acb215685e5125fbcdc40a857eff9de22518820b0a4f4", + "sha256:702a91ade2968a82beb0db1e0766a6a273f33d4616a6ce8cde475d8e09853b20" + ], + "version": "==0.5.0" + }, "django": { "hashes": [ "sha256:a32c22af23634e1d11425574dce756098e015a165be02e4690179889b207c7a8", @@ -24,6 +45,13 @@ "index": "pypi", "version": "==2.1.5" }, + "django-allauth": { + "hashes": [ + "sha256:02175aa1c2ddfd935a54011d1196d70c976647fc46f603f8b8758fc395b9d277" + ], + "index": "pypi", + "version": "==0.37.1" + }, "django-cors-headers": { "hashes": [ "sha256:5545009c9b233ea7e70da7dbab7cb1c12afa01279895086f98ec243d7eab46fa", @@ -55,6 +83,27 @@ "index": "pypi", "version": "==19.6.0" }, + "idna": { + "hashes": [ + "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", + "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" + ], + "version": "==2.8" + }, + "oauthlib": { + "hashes": [ + "sha256:0ce32c5d989a1827e3f1148f98b9085ed2370fc939bf524c9c851d8714797298", + "sha256:3e1e14f6cde7e5475128d30e97edc3bfb4dc857cb884d8714ec161fdbb3b358e" + ], + "version": "==3.0.1" + }, + "python3-openid": { + "hashes": [ + "sha256:0086da6b6ef3161cfe50fb1ee5cceaf2cda1700019fda03c2c5c440ca6abe4fa", + "sha256:628d365d687e12da12d02c6691170f4451db28d6d68d050007e4a40065868502" + ], + "version": "==3.1.0" + }, "pytz": { "hashes": [ "sha256:32b0891edff07e28efe91284ed9c31e123d84bea3fd98e1f72be2508f43ef8d9", @@ -62,12 +111,33 @@ ], "version": "==2018.9" }, + "requests": { + "hashes": [ + "sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e", + "sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b" + ], + "version": "==2.21.0" + }, + "requests-oauthlib": { + "hashes": [ + "sha256:bd6533330e8748e94bf0b214775fed487d309b8b8fe823dc45641ebcd9a32f57", + "sha256:d3ed0c8f2e3bbc6b344fa63d6f933745ab394469da38db16bdddb461c7e25140" + ], + "version": "==1.2.0" + }, "six": { "hashes": [ "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" ], "version": "==1.12.0" + }, + "urllib3": { + "hashes": [ + "sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39", + "sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22" + ], + "version": "==1.24.1" } }, "develop": {} diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 2a1a5530382cc2affd37e357a256cd3fa46289dd..43dd0a70ac73808220ed2638b5dc6c8b5c5a8e6c 100644 GIT binary patch delta 4832 zcmcgweN0=|6~FhM$5*fk1c*r>#eq<8`0#tretvccOGpBQg6%*c6uQha_5&OIRojF> zr#VFFAN^-r^8V1Qpm4^-yx)!D$|&%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Z<<}>J*^zwLXfeYh^A#7PL?V7d$B3Wppl$cZ-0p3>Sow$ld1)6PT{zvsbkfq$ z+DhLGO(YNJ(+}11LBf5NUBWUw6NzkUIH>U0S5I(9rLHMa%%>8vd1Dhrag&Mrvx$n% zqA&f&+<%Yh--sC$%<2Y3p>Ma}JAWh2Mwr6SRJL0Zrf{>z%Mbqb)JL;6x|MHVc#(B@ z_+sT5V}0Qj*nK^Lt{z!=&fnc72Yg2Qo3j!ebeUIw*Ca~%DK(ZaziB`4f8|ueF(p3S zU(jYWB|5a*7Yz^QH94BshF{KVGdV>a>dVK&`q5}1rf3CqI$k(19p%5=Ca?28 z9aSTPV`^64sm%BKL$QFmpYQvk)!FTlA8~); z#xdqF+v&k0ibu?jT?1cVua@Qs=0$c9e11jUL~)(qy2zIxwd2(qzPRE&wJOz`9Vy;! PvA0XC{*EdMw1)i)68}4Y diff --git a/back/reimbursinator/urls.py b/back/reimbursinator/urls.py index 62397e8..b39c33f 100644 --- a/back/reimbursinator/urls.py +++ b/back/reimbursinator/urls.py @@ -13,5 +13,6 @@ urlpatterns = [ path('admin/', admin.site.urls), path('api/v1/', include("backend.urls")), path('api/v1/account/', include('rest_auth.urls')), + path('api/v1/account/register/', include('rest_auth.registration.urls')), path('api-auth/', include('rest_framework.urls')), ] From 6e8478cf67766efea942ca7849aaff3c6f9c94e5 Mon Sep 17 00:00:00 2001 From: kououken Date: Tue, 5 Feb 2019 15:38:34 -0800 Subject: [PATCH 3/5] Changed to email instead of username, added first and last name. --- back/db.sqlite3 | Bin 71680 -> 89088 bytes back/reimbursinator/settings.py | 12 ++++++++ back/reimbursinator/urls.py | 1 + back/users/serializers.py | 47 ++++++++++++++++++++++++++++++++ back/users/views.py | 2 -- 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 back/users/serializers.py diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 43dd0a70ac73808220ed2638b5dc6c8b5c5a8e6c..85281da711c907b2d1d5a7697864a5705948c739 100644 GIT bin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YP_dg>rW>_e&JDa z@aMMHBZS*b_4Rn7hF+g7T{Q>(tG7%S+_B`%`B34GWSLW!#k@N(6pRFhDrBkB?D4jn zJsr)><_?d$rNc#ocMhtzPnHnSK%=TXwFBnQ$8HsD4x40C!)M>rFDt|q2+qMv;DHkI zEqR-yh!LN{`*8)USOHcmrmkuz_xaWyZJsibx9Ptsq$C?+KCw08>1v4kMqMLHY(Vn0 zw@99?F2URAvin9m6N=an=}vaXlvpC_-P#)W(d(BM(On;CF;CB2%(U4&Te}lJQQ7Nl zZ;dFU9d^%Xcg!;yw|PYOsFLj1qjYsL@)n`H%PlCQab9U}vAI+HUlJ8+?@M$(*NIDG zM33P jxJoP!WM`rzdcSh0Z2~oQ&#w$jbwaIrY~YI=wNC0G&bT3@HOESkW+DIBTKGY|Ya8Ev>Fi z?Jl#Mm4Bz%!qnB+sxkFQ59oBIN+)+=`ov^g8RI_N$aLHzVH8cF7O!@EtygR6s>kC^ zbmQzs&7Az|>C>~y!a37ouCU~8On)?FsZ_1^F6%THZX&qJBK!`_C0K)W`FIVNYvU(! zlQo!5=I%law-DT#%R?~2n*6^x7_b55Au}Q$ks*A68JF4fz@RmEk87k(jmcfk@-QE| zRfvmQ+5RWv>)W-a>T0~dG8^bigde!{=c0Xhy?(wp?VC0?yUdn{w{vYqKfb$y?yf5~ zO8ou)svI}B(Ur4HScPBEJffao&ARY$J?1zl!$%KkjkuO|QW~E)T8ukL0YDtV6ub^` NmVPfBiktAOzXP4Y3AX?M diff --git a/back/reimbursinator/settings.py b/back/reimbursinator/settings.py index 503958c..8725757 100644 --- a/back/reimbursinator/settings.py +++ b/back/reimbursinator/settings.py @@ -45,6 +45,7 @@ INSTALLED_APPS = [ 'rest_framework.authtoken', 'allauth', 'allauth.account', + 'allauth.socialaccount', 'rest_auth', 'rest_auth.registration', 'corsheaders', @@ -159,3 +160,14 @@ STATIC_URL = '/static/' EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' SITE_ID = 1 + +# Registration + +ACCOUNT_USER_MODEL_USERNAME_FIELD = 'username' +ACCOUNT_EMAIL_REQUIRED = True +ACCOUNT_USERNAME_REQUIRED = False +ACCOUNT_AUTHENTICATION_METHOD = 'email' + +REST_AUTH_REGISTER_SERIALIZERS = { + 'REGISTER_SERIALIZER': 'users.serializers.RegisterSerializer', +} diff --git a/back/reimbursinator/urls.py b/back/reimbursinator/urls.py index b39c33f..7a33b6d 100644 --- a/back/reimbursinator/urls.py +++ b/back/reimbursinator/urls.py @@ -14,5 +14,6 @@ urlpatterns = [ path('api/v1/', include("backend.urls")), path('api/v1/account/', include('rest_auth.urls')), path('api/v1/account/register/', include('rest_auth.registration.urls')), + # path('api/v1/account/register/', NameRegistrationView.as_view()), path('api-auth/', include('rest_framework.urls')), ] diff --git a/back/users/serializers.py b/back/users/serializers.py new file mode 100644 index 0000000..91416a4 --- /dev/null +++ b/back/users/serializers.py @@ -0,0 +1,47 @@ +from rest_framework import serializers +from allauth.account import app_settings as allauth_settings +from allauth.utils import email_address_exists +from allauth.account.adapter import get_adapter +from allauth.account.utils import setup_user_email +from django.utils.translation import gettext as _ + +class RegisterSerializer(serializers.Serializer): + email = serializers.EmailField(required=allauth_settings.EMAIL_REQUIRED) + first_name = serializers.CharField(required=True, write_only=True) + last_name = serializers.CharField(required=True, write_only=True) + password1 = serializers.CharField(required=True, write_only=True) + password2 = serializers.CharField(required=True, write_only=True) + + def validate_email(self, email): + email = get_adapter().clean_email(email) + if allauth_settings.UNIQUE_EMAIL: + if email and email_address_exists(email): + raise serializers.ValidationError( + _("A user is already registered with this e-mail address.")) + return email + + def validate_password1(self, password): + return get_adapter().clean_password(password) + + def validate(self, data): + if data['password1'] != data['password2']: + raise serializers.ValidationError( + _("The two password fields didn't match.")) + return data + + def get_cleaned_data(self): + return { + 'first_name': self.validated_data.get('first_name', ''), + 'last_name': self.validated_data.get('last_name', ''), + 'password1': self.validated_data.get('password1', ''), + 'email': self.validated_data.get('email', ''), + } + + def save(self, request): + adapter = get_adapter() + user = adapter.new_user(request) + self.cleaned_data = self.get_cleaned_data() + adapter.save_user(request, user, self) + setup_user_email(request, user, []) + user.save() + return user diff --git a/back/users/views.py b/back/users/views.py index 91ea44a..2536b37 100644 --- a/back/users/views.py +++ b/back/users/views.py @@ -1,3 +1 @@ from django.shortcuts import render - -# Create your views here. From bdddb3cc033d613b2cd0aafb71b8223bdfc56b64 Mon Sep 17 00:00:00 2001 From: kououken Date: Tue, 5 Feb 2019 15:49:03 -0800 Subject: [PATCH 4/5] Changed username frank to frank@frank.com. Password is still frank12345 --- back/db.sqlite3 | Bin 89088 -> 89088 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 85281da711c907b2d1d5a7697864a5705948c739..1b759a475639ad1b2f16c066053118c728aac9a2 100644 GIT binary patch delta 601 zcmZqJ!P>Bcb%HeSMFs|ja42S+sA0}{abp4tH>3RKRPH${+)O(em>Js`m?Ih6HuD%% zF$y%AF!3=oYC3Xgi_2JEx8S8?!P4^Bran=IzYN%#)aNftvZ5RaBUL z8OzK}jV;TJ3-Sx|&8o6;GBS*pp{1^Yk*lbMMGOh}t(nTZXFbzC)1(`51>u}vC5 zQw_Ma4lV@2U*IC#MOv^3BE_}f&ZXNfTq&drC${bc7vJH2=icve4!5&s>FilvOgaw< zf>=8Z)9y8aJnXHT?c@y3+245V#s!!H1gNHc>|oj?o!-ziI#VqphLsi=w7~GQi1Q=K z&mtP}ynsZb+Zw}!f^LammXdjOx$=3$g$#|#J zX|)9jT}GODXWHb_572{A#_tvVh^JW*`B))e*Ds(ey2_Ou9PeiZn)UJ$$Kx;D;`kr! z@ST94aD*MvPjIPVHME@@IzSl*+i;aLR&bM>ja(gUFhSxUE9d8724tOT1@PFE4Y2&E zZ#I~cPIZRNRnSY%UXPG4Fgg%k7+}}uBfx{_w)s&DL<#r?QRu@?#%wT~$rryWluM{80BN695yd57gkzK;{ z(ST*0HH+&{Z%`JwYYG0ZuYy)NwY`ee;u0^f#fu8MT~Z=<%dyD)QY@U@mJ@1IEhZT` zyyR69@eLWt23Hewr8hyg^y6Mbe}_Y3((sF%`g^ie_iN`dHcuVH?j4FG`__BpFZd0A Ck-3rp From d683ea8839495650e6a4631489884629aec4f398 Mon Sep 17 00:00:00 2001 From: kououken Date: Wed, 6 Feb 2019 13:22:40 -0800 Subject: [PATCH 5/5] Fixed user authentication backend to allow login with email. --- back/db.sqlite3 | Bin 89088 -> 89088 bytes back/reimbursinator/settings.py | 9 +++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 1b759a475639ad1b2f16c066053118c728aac9a2..8074d09696b7ab103c40188a656433376bef08ba 100644 GIT binary patch delta 1175 zcma)5U2NM_6t;bmI!=GmrVSgTgETEa8*RAP|87+=Z%wWB)GEN$x432WE2 z%{0-Bkv<`T{Ln|9c%8HwkqLDm?Wx++KunVWF$p0M5~_GWn%Kj{bp_H;CxLYQ`Cj|; zIp25g@%jz_`VIew&(M!P>ODa}y8iYTL7H`*YfT)8^>8pmFE14rm) ztf;D>5*29@rDF7W)y|XMF>=KVReRqjNM_>-(o{)y8o24BDCz@8=QqOjj(Qt-La9I` za`?pnCpdlhDJRd54xSc`9AQC{RrhNF z^>qA90o-BW0o;LI*mXNkegoa4K1BtH*kAx6dtC+h!BqPo#6WV`)mK|UhY^t6uHIjn zupelei|t|G9!A}XOE-Oln{n86!p*^(kRjYw2>F1cV;=N*5OrtY`vm#>;UqNO&QA|O zv>=vpYgJ3OD`mbatSA_-u9WR%RV-WObE^H0JJDzr!Y<%9dPg&Wq<7LAdFD0#{W%6gs$qBN`7$|ES zYpL`kGSdb!YG-gV?L_bON(p4xr}^we0%t7~8}=m1j_I`|Z?2lPIVo#Ru9#`^#>!fT zWs0U{3gqsbzjug!!|A-6f0C7}ci(5&hu&dOGU?h6;Ou_a*5Y+G$Zmaq0ZwSRD9Bn- zIfn{zF)s_6$ZI*NAc{pv%;&skSQb>2d%~2(HAzx6A?P;m{{ch)HxctP%y7=l`!8+% z^e50k_u((0gZ|%O8@7qQYp}TubbO$vCCs)^0gmnuJ~rt=Z<5G7!|$*IJB0o@Z0@l1 z3*jyZK|lQ%ll?3}`(A7FF}EmaK$h8MZV~zxlQ|mWD7~w@o#yC$jwCHEs#wxwj7TaD ztiB+nha&aX{bV$Z<+#FYq9O|3ui|{XacJ|$41I89Fd8e`x%q|I%;n279CI{E>V+cv a>tStJ;NudOu_9>s`Go}znvD!y^Zf;2dqN8U delta 786 zcma)4OHUI~6u!5o(+=-~yo@AmA_@jt=Ka7BTOPJb2@5f%3nN3Bu@!3RgG!4FR4iM~ zEcgZPjERh~Xh65b6&Q7+kqwE7iL6YBuDsKo#zgbwo}7I5%gJ{hE1T5HCiUP1-h0?J zg7=8%^<@V3@~A1~(gZ0=foF_%xL?3}ii>(;s(Um(C`1TkE8454Y$!@L>Q zvRdL&HKdaHM9$8F)fkAUQyjypeunciqL1STd0~)K0+OtVs)P{kM|aL3x~JeS@u|F$nH*S(go;A(;(%Hj4XLUaRpbld@#sh1nATz8aSZ{fzwecGQ*hO#zyKn#pmM8KKj?vIo9S73Qvg~19hZ#xNNnC=yu@quOBd&E!?sK80f^Q;4W1xe)90>6;Xq@~i0`9zW{ zhzUVvZxxGrHkDko!j*cug;njz3CbWZ2SkSDS>DoL@3opir>FPsSvNJYN`?Me>FWnK zZu+y#>ihc+_aP7u34?12kl@VS}mcG6Cv2KLF6xCeaDSYw-CDJHzho$u`}wzK<>Cqgtwtm IzJg26Un7R*n*aa+ diff --git a/back/reimbursinator/settings.py b/back/reimbursinator/settings.py index 8725757..86f1b58 100644 --- a/back/reimbursinator/settings.py +++ b/back/reimbursinator/settings.py @@ -163,11 +163,16 @@ SITE_ID = 1 # Registration -ACCOUNT_USER_MODEL_USERNAME_FIELD = 'username' +#ACCOUNT_USER_MODEL_USERNAME_FIELD = 'email' ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_USERNAME_REQUIRED = False ACCOUNT_AUTHENTICATION_METHOD = 'email' REST_AUTH_REGISTER_SERIALIZERS = { - 'REGISTER_SERIALIZER': 'users.serializers.RegisterSerializer', + 'REGISTER_SERIALIZER': 'users.serializers.RegisterSerializer', } + +AUTHENTICATION_BACKENDS = ( + 'django.contrib.auth.backends.ModelBackend', + 'allauth.account.auth_backends.AuthenticationBackend', +)