Example #1
0
    def post(self, request):
        password = request.POST['password']
        vendor = request.POST['vendor']
        if vendor == 'aws':
            access_key = request.POST['aws_access_key']
            secret_key = request.POST['aws_secret_key']
            region = request.POST['aws_region']
            credential = {
                'access_key': access_key,
                'secret_key': secret_key,
                'region': region
            }

            if not request.user.check_password(password):
                Util.add_alert(request, '비밀번호가 틀렸습니다.')
                return redirect('apps')

            if not Util.is_valid_access_key(access_key, secret_key):
                Util.add_alert(request, '올바른 백엔드 인증 정보를 입력해주세요.')
                return redirect('apps')

            request.user.set_credential(password, vendor, credential)
            request.user.save()

            credentials = request.user.get_credentials(password)
            Util.reset_credentials(request, credentials)
            Util.add_alert(request, '백엔드 인증 정보를 변경하였습니다.')
            return redirect('apps')
Example #2
0
 def post(self, request):
     email = request.POST.get('email', None)
     password = request.POST.get('password', None)
     otp_code = request.POST.get('otp_code', None)
     if otp_code and password:
         email = request.session['email']
         if self.verify_otp_code(email, otp_code):
             user = authenticate(username=email, password=password)
             request.session['email'] = None
             if user is None:
                 Util.add_alert(request, '로그인 정보가 틀렸습니다.')
                 request.session['otp_hidden'] = True
                 return redirect('login')
             else:
                 credentials = user.get_credentials(password)
                 Util.reset_credentials(request, credentials)
                 login(request, user)
                 request.session['otp_hidden'] = True
                 return redirect(settings.LOGIN_REDIRECT_URL)
         else:
             Util.add_alert(request, '인증번호가 틀렸습니다.')
             request.session['otp_hidden'] = True
             return redirect('login')
     elif email:
         self.send_otp_email(email)
         request.session['email'] = email
         Util.add_alert(request, '이메일로 인증번호가 전송되었습니다.')
         request.session['otp_hidden'] = False
         return redirect('login')
     else:
         Util.add_alert(request, '모든 정보를 입력헤주세요.')
         request.session['otp_hidden'] = False
         return redirect('login')
Example #3
0
    def post(self, request):
        email = request.POST['email']
        password = request.POST['password']
        user = authenticate(username=email, password=password)

        if user is None:
            Util.add_alert(request, '로그인 정보가 틀렸습니다')
            return redirect('login')
        else:
            credentials = user.get_credentials(password)
            Util.reset_credentials(request, credentials)
            login(request, user)
            return redirect(settings.LOGIN_REDIRECT_URL)
Example #4
0
    def post(self, request):
        password = request.POST['password']
        new_password = request.POST['new_password']

        credentials = request.user.get_credentials(password)
        if not request.user.check_password(password):
            Util.add_alert(request, '비밀번호가 틀렸습니다.')
            return redirect('apps')

        request.user.set_password(new_password)
        request.user.save()

        request.user.set_credentials(new_password, credentials)
        request.user.save()

        credentials = request.user.get_credentials(new_password)
        Util.reset_credentials(request, credentials)
        Util.add_alert(request, '비밀번호를 변경하였습니다.')
        return redirect('apps')
Example #5
0
 def get(self, request):
     Util.reset_credentials(request)
     logout(request)
     return redirect('index')