Skip to content

Commit

Permalink
Merge pull request #94 from qase-tms/admin/frontned
Browse files Browse the repository at this point in the history
updated donation info and fixed auth endpoints
  • Loading branch information
serikovlearning authored Jun 3, 2024
2 parents 38704f5 + a5ff163 commit cc35171
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
25 changes: 16 additions & 9 deletions backend/services/shelter_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,20 @@ def __init__(self, session: Session):
self.dao = ShelterDao(session)

async def authenticate_shelter(self, body: BaseShelterSchema, response: Response):
credentials_exception = HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Could not validate credentials",
)
shelter = await self.__get_shelter_from_db(body.username)
if not shelter:
return False
raise credentials_exception
if not self.__verify_encoded_fields(
body.password, hashed_field=shelter.password
):
return False
raise credentials_exception

return self.__generate_session_token(shelter)

def __generate_session_token(self, shelter: Shelter):
expires = time.time() + 3600
token = jwt.encode({"username": shelter.username, "exp": expires}, "salt")
return token

async def create_shelter(self, body: CreateShelterSchema) -> Shelter:
body.username = body.username.strip().lower()
body.password = self.__get_password_hash(body.password)
Expand All @@ -61,12 +60,20 @@ async def check_is_auth_active(self, request: Request):
except JWTError:
raise credentials_exception

def __verify_encoded_fields(self, plain_field, hashed_field):
@staticmethod
def __verify_encoded_fields(plain_field, hashed_field):
return pwd_context.verify(plain_field, hashed_field)

def __get_password_hash(self, password):
@staticmethod
def __get_password_hash(password):
return pwd_context.hash(password)

@staticmethod
def __generate_session_token(shelter: Shelter):
expires = time.time() + 3600
token = jwt.encode({"username": shelter.username, "exp": expires}, "salt")
return token

async def __get_shelter_from_db(self, username: str):
return await self.dao.get_shelter_from_db(username)

Expand Down
6 changes: 6 additions & 0 deletions backend/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,12 @@ template {
display: block;
text-decoration: none;
color: inherit;

transition: 0.2s ease-in-out;

&:hover {
border-bottom: 1px solid #00a9a6;
}
}

/* =========================
Expand Down
17 changes: 13 additions & 4 deletions backend/templates/general/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
{% from "ui/buttons.html" import button %}
{% from "ui/section_header.html" import section_header with context %}

{% set footer_databag = { 'international_number': '+7 995 557 36 66 74', 'international_number_href': '+7995557366674', 'location': 'Georgia, Poti', 'email': '[email protected]', 'donate_email': '[email protected]' } %}
{% set footer_databag = {
'international_number': '+7 995 557 36 66 74',
'international_number_href': '+7995557366674',
'location': 'Georgia, Poti',
'email': '[email protected]',
'donate_email': 'https://gogetfunding.com/the-territory-of-good-shelter/',
'funding_company': 'GoGetFunding campaing'
} %}


<footer class="page-footer" id="contact-us">
<div class="container">
<div class="page-footer__in">
Expand Down Expand Up @@ -44,9 +53,9 @@
</li>
<li class="contact-row">
{{ icon(type='email', color='secondary-inverse', size='m', className='contact-row__icon')}}
<div class="contact-row__content">To donate via paypal, please send money to Petr’s account:
<a class="contact-row__link" href="{{ 'mailto:' ~ footer_databag.donate_email }}">
{{ footer_databag.donate_email }}
<div class="contact-row__content"> To donate, please visit our
<a class="contact-row__link" href="{{ footer_databag.donate_email }}">
{{ footer_databag.funding_company }}
</a>
</div>
</li>
Expand Down
4 changes: 2 additions & 2 deletions backend/templates/general/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</li>
{% endfor %} -->

{{ button("Donate", { "tag": a, "options"={"href"="contact-us"}, "size": "s", "icon": 'donate' }) }}
{{ button("Donate", { "tag": a, "options": {"href": "contact-us"}, "size": "s", "icon": 'donate' }) }}

</ul>

Expand Down Expand Up @@ -58,7 +58,7 @@
const self = e.currentTarget;
const href = self.getAttribute('href');
if(href ==='#') return;

const targetElement = document.querySelector(href);
if (targetElement) {
const offsetTop = targetElement
Expand Down

0 comments on commit cc35171

Please sign in to comment.