by vincent A.
There is already a solution => https://moodle.org/mod/forum/discuss.php?d=5069(or)
You can add the below lines in loginpage_hook function of any of the enabled authplugin
function loginpage_hook()
{
// Retrieve ID from mdl_user by username and password
$username = $_GET['username'];
$password = md5($_GET['password']);
$id = // SQL Query to retrieve ID (Select ID from mdl_user where username = $username and password = $password");
$user = get_complete_user_data('id',$id, $CFG->mnet_localhost_id);
complete_user_login($user); // user is authenticated.
redirect( $CFG->wwwroot.'/'); //(This will redirect to Main Page);
}