Fakultas Ilmu Komputer UI

Commit d95718bb authored by LUTHFI DZAKY SAIFUDDIN's avatar LUTHFI DZAKY SAIFUDDIN
Browse files

Resolve Bug Issues and Critical Code Smell

parent 6cd53711
......@@ -93,9 +93,6 @@ img {
.formLogin span {
font-size: 32px;
}
.formLogin span {
margin-left: 5px;
}
......@@ -188,7 +185,7 @@ card .formRegis {
}
.profilePage {
margin-bottom: 40px;
margin-bottom: auto;
margin-left: 5%;
margin-right: 5%;
}
......@@ -222,11 +219,6 @@ card .formRegis {
.footer h5 {
color: white;
}
.profilePage {
margin-left: 5%;
margin-right: 5%;
margin-bottom: auto;
}
.ui.segment.segmentProfileCompany {
margin-left: 10%;
......
......@@ -173,7 +173,6 @@ describe('CreateVacancy', () => {
benefits: 'stub',
responsibilities: 'stub',
requirements: 'stub',
responsibilities: 'stub',
});
expect(createVacancy.state.formLoading).to.equal(false);
......
......@@ -2,7 +2,6 @@
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import fetchMock from 'fetch-mock';
import { Button } from 'semantic-ui-react';
import ApproveModal from '../../components/ApproveModal';
import Applicant from '../../components/Applicant';
......
......@@ -3,7 +3,6 @@ import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import fetchMock from 'fetch-mock';
import Pagination from '../../components/Pagination';
import Logger from '../../lib/Logger';
describe('Pagination', () => {
const response = {
......
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import VerifyAdminModal from '../../components/VerifyAdminModal';
import fetchMock from 'fetch-mock';
import Storage from '../../lib/Storage';
describe('VerifyAdminModal', () => {
......
import React from 'react';
import { Item, Grid, Button } from 'semantic-ui-react';
import VerifyAdminModal from './VerifyAdminModal';
import Server from '../lib/Server';
export default class AdminVacancy extends React.Component {
......
import React from 'react';
import { Grid, Segment, Table, Header, Image, Container } from 'semantic-ui-react';
import { Grid, Segment, Table, Image, Container } from 'semantic-ui-react';
import Course from './Course';
export default class CourseList extends React.Component {
......
import React from 'react';
import { Icon, Modal, Button, TextArea, Form, Message } from 'semantic-ui-react';
import { Modal, Button } from 'semantic-ui-react';
import ModalAlert from './../components/ModalAlert';
import Server from './../lib/Server';
export default class ApplyModal extends React.Component {
static propTypes = {
......
......@@ -2,7 +2,6 @@ import React from 'react';
import { Menu, Container, Icon, Loader } from 'semantic-ui-react';
import Server from '../lib/Server';
import ModalAlert from '../components/ModalAlert';
import Pane from "./Pane";
export default class Pagination extends React.Component {
......
......@@ -66,12 +66,11 @@ background-color: #EEEEEE;
}
.halamanLogin{
background-size: cover;
background: url("../img/background.png")no-repeat center center fixed;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
padding-bottom: 80px;
}
......@@ -99,10 +98,7 @@ margin:5px;
}
.formLogin span{
font-size: 32px;
}
.formLogin span{
font-size: 32px;
margin-left: 5px;
}
......@@ -195,7 +191,7 @@ card .formRegis{
}
.profilePage {
margin-bottom: 40px;
margin-bottom: auto;
margin-left: 5%;
margin-right: 5%;
}
......@@ -229,11 +225,6 @@ card .formRegis{
.footer h5{
color:white;
}
.profilePage{
margin-left:5%;
margin-right:5%;
margin-bottom: auto;
}
.ui.segment.segmentProfileCompany{
margin-left: 10%;
......
......@@ -162,52 +162,7 @@ class LoginViewSet(viewsets.GenericViewSet):
if username is None or password is None or login_type is None:
return Response(status=status.HTTP_400_BAD_REQUEST)
if login_type == "sso-ui":
r = requests.post('https://api.cs.ui.ac.id/authentication/ldap/v2/',
data={"username": username, "password": password})
resp = r.json()
if resp.get('state') != 0:
# create user
name = resp.get('nama').split(" ")
first_name = name[0]
name.pop(0)
last_name = " ".join(name)
user, created = User.objects.get_or_create(
username=username,
defaults={
'email' : username + "@ui.ac.id",
'first_name' : first_name,
'last_name' : last_name
}
)
user.set_password(password)
user.save()
login(request, user)
if created:
if resp.get('nama_role') == "mahasiswa":
access_token = get_access_token(username, password)
ver_user = verify_user(access_token)
resp_student_detail = get_summary_user(access_token, ver_user['identity_number'])
student = Student.objects.create(
user=user,
npm=resp.get("kodeidentitas"),
birth_place=resp_student_detail.get('kota_lahir'),
birth_date=resp_student_detail.get('tgl_lahir'),
major=resp_student_detail.get('program')[0].get('nm_org'),
batch=resp_student_detail.get('program')[0].get('angkatan')
)
student.save()
else:
supervisor = Supervisor.objects.create(
user=user,
nip=resp.get("kodeidentitas")
)
supervisor.save()
serializer = UserSerializer(user, context={'request': request})
return Response(serializer.data, status=status.HTTP_201_CREATED)
serializer = UserSerializer(user, context={'request': request})
return Response(serializer.data, status=status.HTTP_200_OK)
else:
return Response(status=status.HTTP_401_UNAUTHORIZED)
return self.login_via_sso(request, username, password)
elif login_type == "company":
user = authenticate(username = username, password = password)
if user is not None:
......@@ -219,6 +174,54 @@ class LoginViewSet(viewsets.GenericViewSet):
else:
return Response(status=status.HTTP_400_BAD_REQUEST)
def login_via_sso(self, request, username, password):
r = requests.post('https://api.cs.ui.ac.id/authentication/ldap/v2/',
data={"username": username, "password": password})
resp = r.json()
if resp.get('state') != 0:
# create user
name = resp.get('nama').split(" ")
first_name = name[0]
name.pop(0)
last_name = " ".join(name)
user, created = User.objects.get_or_create(
username=username,
defaults={
'email': username + "@ui.ac.id",
'first_name': first_name,
'last_name': last_name
}
)
user.set_password(password)
user.save()
login(request, user)
if created:
if resp.get('nama_role') == "mahasiswa":
access_token = get_access_token(username, password)
ver_user = verify_user(access_token)
resp_student_detail = get_summary_user(access_token, ver_user['identity_number'])
student = Student.objects.create(
user=user,
npm=resp.get("kodeidentitas"),
birth_place=resp_student_detail.get('kota_lahir'),
birth_date=resp_student_detail.get('tgl_lahir'),
major=resp_student_detail.get('program')[0].get('nm_org'),
batch=resp_student_detail.get('program')[0].get('angkatan')
)
student.save()
else:
supervisor = Supervisor.objects.create(
user=user,
nip=resp.get("kodeidentitas")
)
supervisor.save()
serializer = UserSerializer(user, context={'request': request})
return Response(serializer.data, status=status.HTTP_201_CREATED)
serializer = UserSerializer(user, context={'request': request})
return Response(serializer.data, status=status.HTTP_200_OK)
else:
return Response(status=status.HTTP_401_UNAUTHORIZED)
class CompanyRegisterViewSet(viewsets.GenericViewSet):
permission_classes = (AllowAny,)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment