import 'dart:convert';

import 'package:ambito/src/entity/login/login.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:crypto/crypto.dart';
import 'package:isar/isar.dart';

import '../../consts/consts.dart';

class LoginRepository extends BaseDB {
  @override
  IsarCollection collection = isar.logins;

  Login? getLogin(String username, String password) {
    return isar.logins
        .where()
        .usernameEqualTo(username)
        .and()
        .passwordEqualTo(sha1.convert(utf8.encode(password)).toString())
        .findFirst();
  }
}
