Skip to content

Commit

Permalink
Added email address validation
Browse files Browse the repository at this point in the history
EPO-8832 Added email address validation
  • Loading branch information
ericdrosas87 committed Dec 11, 2023
1 parent 3c67820 commit 22c3cbf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "rubin.citsci"
version = "0.2.2"
version = "0.2.3"
readme = "README.md"
dependencies = [
"panoptes_client",
Expand Down
27 changes: 21 additions & 6 deletions src/rubin/citsci/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import csv, uuid, os, shutil, json, logging, urllib.request, base64
import csv, uuid, os, shutil, json, logging, urllib.request, base64, re
from datetime import datetime, timezone, timedelta
from IPython.display import display
import google.cloud.storage as storage
Expand Down Expand Up @@ -61,15 +61,30 @@ def login_to_zooniverse(self, slug_name, email):
platform. If not, please go to the Zooniverse website and create an account:
https://www.zooniverse.org/
Email address validation occurs before the login prompt is called.
"""

self.client = panoptes_client.Panoptes.connect(login="interactive")
self.project = Project.find(slug=slug_name)
self.project_id = self.project.id
self.email = email
print("You now are logged in to the Zooniverse platform.")
valid_email = self.__validate_email_address(email)

if(valid_email):
self.email = email
self.client = panoptes_client.Panoptes.connect(login="interactive")
self.project = Project.find(slug=slug_name)
self.project_id = self.project.id

print("You now are logged in to the Zooniverse platform.")
else:
print("Invalid email address! Please check the email address you provided and ensure it is correct.")
return

def __validate_email_address(email):
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
if re.fullmatch(regex, email):
return True
else:
return False

def create_project(self, name, description, make_active_project=False):
"""
Assuming you have a Zooniverse account and have used the login_to_zooniverse()
Expand Down

0 comments on commit 22c3cbf

Please sign in to comment.