DEV Community

Ali Buğra Okkalı for Açıklab

Posted on

5 1

Liman Üzerinde Fonksiyon Yetkileri

Bir Liman eklentisinde fonksiyon yetkilendirmesinin nasıl yapıldığını inceleyeceğiz.

Örnek olarak Training eklentisindeki "Task Çalıştır" butonunu yetkiye göre görünür hale getirelim.

Image description

db.json

db.json'a aşağıdaki array'i ekleyelim. Array'in her bir elemanı bir fonksiyon yetkisine karşılık gelir.

name: Fonksiyon Adı
description: Açıklama
isActive: Yetki Sistemine Dahil Et
display: Sunucu Loglarında Görüntüle

"functions": [
        {
            "name": "runTask",
            "description": "RUN_TASK",
            "isActive": "true",
            "display": "true"
        }
],
Enter fullscreen mode Exit fullscreen mode

views/taskview/main.blade.php

Butonun olduğu dosyaya gidip butonu db.json'da tanımladığımız fonksiyon yetkisi ile bağlayalım.

...
  @if(can('runTask'))
    <button class="btn btn-primary" onclick="exampleTask()"><i class="fas fa-check-circle"></i> {{ __("Task çalıştır") }}</button>
  @else
    <b> Task Çalıştırmak İçin Yetkiniz Yok ! </b>
  @endif
...
Enter fullscreen mode Exit fullscreen mode

Test

  • Yetkisiz Kullanıcı

Liman arayüzünden yeni bir kullanıcı oluşturalım. Eklentinin çalıştığı sunucuya ve eklentiye yetki verelim. O kullanıcı ile giriş yaptığımızda eklentide butonun yerine bir uyarı mesajı olduğunu görebiliriz.

Image description

  • Yetkili Kullanıcı

Aynı kullanıcıya Administrator hesabı ile arayüzden fonksiyon yetkisi verelim.

Image description

Kullanıcı uyarı mesajı yerine butonu görebilir hale geldi.

Image description

Image of AssemblyAI tool

Challenge Submission: SpeechCraft - AI-Powered Speech Analysis for Better Communication

SpeechCraft is an advanced real-time speech analytics platform that transforms spoken words into actionable insights. Using cutting-edge AI technology from AssemblyAI, it provides instant transcription while analyzing multiple dimensions of speech performance.

Read full post

Top comments (0)

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay