Skip to content

Commit

Permalink
minor changes in readme and files
Browse files Browse the repository at this point in the history
  • Loading branch information
DiptoChakrabarty committed Oct 5, 2020
1 parent 2a67eff commit f0a936b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@


### How to run the project :horse_racing:

##### To run locally
```sh
* Clone the repository
git clone https://github.com/DiptoChakrabarty/flask-online-store.git
Expand Down Expand Up @@ -46,6 +48,23 @@
(it is preferable if you use something as postman as most are post requests)


```
##### To run in docker
```sh
* Set environment variables
cp .env.example .env

* Fill the required parameters

* If you have removed site.db remove teh following line in Dockerfile
RUN rm site.db

* Run using
docker-compose up -d to start as background process

* Head over to http://localhost:5000

```
## Repository Structure :deciduous_tree:
Expand Down
Binary file modified model/__pycache__/users.cpython-36.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions model/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class UserModel(db.Model):
username = db.Column(db.String(20),nullable=False,unique=True)
password = db.Column(db.String(20),nullable=True)
email = db.Column(db.String(40),nullable=False,unique=True)
activated = db.Column(db.Boolean,default=False) #set default as False
activated = db.Column(db.Boolean,default=False) #set default as False , if you do not email verification set as True
seller = db.Column(db.Boolean, default=False)

def __init__(self,username,password,email,activated=True,seller=False):
def __init__(self,username,password,email,activated=False,seller=False): # if you do not email verification set activated as True
self.username=username
self.password=password
self.email = email
Expand Down
17 changes: 10 additions & 7 deletions resource/github_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ def get(cls):
return github.authorize(url_for("github.authorize",_external=True))

class GithubAuthorize(Resource):


#generate a sample password for github oauth users
@classmethod
def generate_sample_password(cls):
alpha = string.ascii_letters + string.digits
random = ''.join(secrets.choice(alpha) for i in range(20))
return random


@classmethod
def get(cls):
response = github.authorized_response()
Expand All @@ -31,13 +41,6 @@ def get(cls):
#if UserModel.find_by_username(github_username):
# return {"msg": "User with username exists"}

#generate a sample password for github oauth users
@classmethod
def generate_sample_password(cls):
alpha = string.ascii_letters + string.digits
random = ''.join(secrets.choice(alpha) for i in range(20))
return random

#add user to database
user = UserModel(username=github_username,password=GithubAuthorize.generate_sample_password(),activated=True,email=github_email)
user.save_to_db()
Expand Down
Binary file modified site.db
Binary file not shown.

0 comments on commit f0a936b

Please sign in to comment.